From 2e266d5ae53296ce9b647c2318b42b2d9111a7b1 Mon Sep 17 00:00:00 2001 From: JP Rosevear Date: Tue, 22 Jun 2004 22:35:41 +0000 Subject: HIGify and newer design; alarm page is gone, Cancel/OK buttons for the 2004-06-22 JP Rosevear * gui/dialogs/Makefile.am, gui/dialogs/alarm-dialog.c, gui/dialogs/alarm-dialog.glade, gui/dialogs/alarm-dialog.h, gui/dialogs/alarm-list-dialog.c, gui/dialogs/alarm-list-dialog.glade, gui/dialogs/alarm-list-dialog.h, gui/dialogs/alarm-options.c, gui/dialogs/alarm-options.h, gui/dialogs/alarm-page.c, gui/dialogs/alarm-page.glade, gui/dialogs/alarm-page.h, gui/dialogs/comp-editor.c, gui/dialogs/comp-editor.h, gui/dialogs/event-editor.c, gui/dialogs/event-page.c, gui/dialogs/event-page.glade, gui/dialogs/meeting-page.c, gui/dialogs/meeting-page.glade, gui/dialogs/recurrence-page.c, gui/dialogs/recurrence-page.glade, gui/dialogs/task-details-page.c, gui/dialogs/task-details-page.glade, gui/dialogs/task-editor.c, gui/dialogs/task-page.c, gui/dialogs/task-page.glade: HIGify and newer design; alarm page is gone, Cancel/OK buttons for the dialog, no more menus; slightly improve read-only workings for entry areas svn path=/trunk/; revision=26463 --- calendar/ChangeLog | 21 + calendar/gui/dialogs/Makefile.am | 6 + calendar/gui/dialogs/alarm-dialog.c | 324 ++++++++ calendar/gui/dialogs/alarm-dialog.glade | 336 +++++++++ calendar/gui/dialogs/alarm-dialog.h | 37 + calendar/gui/dialogs/alarm-list-dialog.c | 244 +++++++ calendar/gui/dialogs/alarm-list-dialog.glade | 219 ++++++ calendar/gui/dialogs/alarm-list-dialog.h | 38 + calendar/gui/dialogs/alarm-options.c | 8 +- calendar/gui/dialogs/alarm-options.h | 2 +- calendar/gui/dialogs/alarm-page.c | 897 ----------------------- calendar/gui/dialogs/alarm-page.glade | 545 -------------- calendar/gui/dialogs/alarm-page.h | 62 -- calendar/gui/dialogs/comp-editor.c | 553 +++++--------- calendar/gui/dialogs/comp-editor.h | 15 +- calendar/gui/dialogs/event-editor.c | 69 +- calendar/gui/dialogs/event-page.c | 428 ++++++++--- calendar/gui/dialogs/event-page.glade | 1016 +++++++++++++++----------- calendar/gui/dialogs/meeting-page.c | 38 +- calendar/gui/dialogs/meeting-page.glade | 502 +++++++++---- calendar/gui/dialogs/recurrence-page.c | 337 ++++----- calendar/gui/dialogs/recurrence-page.glade | 925 +++++++++++------------ calendar/gui/dialogs/task-details-page.c | 32 +- calendar/gui/dialogs/task-details-page.glade | 628 +++++++++------- calendar/gui/dialogs/task-editor.c | 61 +- calendar/gui/dialogs/task-page.c | 116 ++- calendar/gui/dialogs/task-page.glade | 765 ++++++++++--------- 27 files changed, 4141 insertions(+), 4083 deletions(-) create mode 100644 calendar/gui/dialogs/alarm-dialog.c create mode 100644 calendar/gui/dialogs/alarm-dialog.glade create mode 100644 calendar/gui/dialogs/alarm-dialog.h create mode 100644 calendar/gui/dialogs/alarm-list-dialog.c create mode 100644 calendar/gui/dialogs/alarm-list-dialog.glade create mode 100644 calendar/gui/dialogs/alarm-list-dialog.h delete mode 100644 calendar/gui/dialogs/alarm-page.c delete mode 100644 calendar/gui/dialogs/alarm-page.glade delete mode 100644 calendar/gui/dialogs/alarm-page.h diff --git a/calendar/ChangeLog b/calendar/ChangeLog index f293ba476c..ebae1dc77a 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,24 @@ +2004-06-22 JP Rosevear + + * gui/dialogs/Makefile.am, gui/dialogs/alarm-dialog.c, + gui/dialogs/alarm-dialog.glade, gui/dialogs/alarm-dialog.h, + gui/dialogs/alarm-list-dialog.c, + gui/dialogs/alarm-list-dialog.glade, + gui/dialogs/alarm-list-dialog.h, gui/dialogs/alarm-options.c, + gui/dialogs/alarm-options.h, gui/dialogs/alarm-page.c, + gui/dialogs/alarm-page.glade, gui/dialogs/alarm-page.h, + gui/dialogs/comp-editor.c, gui/dialogs/comp-editor.h, + gui/dialogs/event-editor.c, gui/dialogs/event-page.c, + gui/dialogs/event-page.glade, gui/dialogs/meeting-page.c, + gui/dialogs/meeting-page.glade, gui/dialogs/recurrence-page.c, + gui/dialogs/recurrence-page.glade, + gui/dialogs/task-details-page.c, + gui/dialogs/task-details-page.glade, gui/dialogs/task-editor.c, + gui/dialogs/task-page.c, gui/dialogs/task-page.glade: HIGify and + newer design; alarm page is gone, Cancel/OK buttons for the + dialog, no more menus; slightly improve read-only workings for + entry areas + 2004-06-22 JP Rosevear * gui/e-meeting-time-sel.c (e_meeting_time_selector_construct): diff --git a/calendar/gui/dialogs/Makefile.am b/calendar/gui/dialogs/Makefile.am index dfe84f1a3c..393d9744be 100644 --- a/calendar/gui/dialogs/Makefile.am +++ b/calendar/gui/dialogs/Makefile.am @@ -32,6 +32,10 @@ noinst_LTLIBRARIES = libcal-dialogs.la libcal_dialogs_la_SOURCES = \ $(IDL_GENERATED) \ + alarm-dialog.c \ + alarm-dialog.h \ + alarm-list-dialog.c \ + alarm-list-dialog.h \ alarm-options.c \ alarm-options.h \ alarm-page.c \ @@ -86,6 +90,8 @@ libcal_dialogs_la_SOURCES = \ url-editor-dialog.h glade_DATA = \ + alarm-dialog.glade \ + alarm-list-dialog.glade \ alarm-options.glade \ alarm-page.glade \ cal-prefs-dialog.glade \ diff --git a/calendar/gui/dialogs/alarm-dialog.c b/calendar/gui/dialogs/alarm-dialog.c new file mode 100644 index 0000000000..0b886eabba --- /dev/null +++ b/calendar/gui/dialogs/alarm-dialog.c @@ -0,0 +1,324 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ + +/* Evolution calendar - Alarm page of the calendar component dialogs + * + * Copyright (C) 2001-2003 Ximian, Inc. + * + * Authors: Federico Mena-Quintero + * Miguel de Icaza + * Seth Alves + * JP Rosevear + * Hans Petter Jansson + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "e-util/e-dialog-widgets.h" +#include "e-util/e-time-utils.h" +#include +#include +#include "e-util/e-dialog-widgets.h" +#include "e-util/e-icon-factory.h" +#include "../calendar-config.h" +#include "comp-editor-util.h" +#include "alarm-options.h" +#include "alarm-dialog.h" + + + +typedef struct { + /* Glade XML data */ + GladeXML *xml; + + /* The alarm */ + ECalComponentAlarm *alarm; + + /* The client */ + ECal *ecal; + + /* Toplevel */ + GtkWidget *toplevel; + + GtkWidget *action; + GtkWidget *interval_value; + GtkWidget *value_units; + GtkWidget *relative; + GtkWidget *time; + + GtkWidget *button_options; +} Dialog; + +/* "relative" types */ +enum { + BEFORE, + AFTER +}; + +/* Time units */ +enum { + MINUTES, + HOURS, + DAYS +}; + +/* Option menu maps */ +static const int action_map[] = { + E_CAL_COMPONENT_ALARM_DISPLAY, + E_CAL_COMPONENT_ALARM_AUDIO, + E_CAL_COMPONENT_ALARM_PROCEDURE, + E_CAL_COMPONENT_ALARM_EMAIL, + -1 +}; + +static const char *action_map_cap[] = { + CAL_STATIC_CAPABILITY_NO_DISPLAY_ALARMS, + CAL_STATIC_CAPABILITY_NO_AUDIO_ALARMS, + CAL_STATIC_CAPABILITY_NO_PROCEDURE_ALARMS, + CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS +}; + +static const int value_map[] = { + MINUTES, + HOURS, + DAYS, + -1 +}; + +static const int relative_map[] = { + BEFORE, + AFTER, + -1 +}; + +static const int time_map[] = { + E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START, + E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_END, + -1 +}; + +/* Fills the widgets with default values */ +static void +clear_widgets (Dialog *dialog) +{ + /* Sane defaults */ + e_dialog_option_menu_set (dialog->action, E_CAL_COMPONENT_ALARM_DISPLAY, action_map); + e_dialog_spin_set (dialog->interval_value, 15); + e_dialog_option_menu_set (dialog->value_units, MINUTES, value_map); + e_dialog_option_menu_set (dialog->relative, BEFORE, relative_map); + e_dialog_option_menu_set (dialog->time, E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START, time_map); +} + +/* fill_widgets handler for the alarm page */ +static void +alarm_to_dialog (Dialog *dialog) +{ + GtkWidget *menu; + GList *l; + int i; + + /* Clean the page */ + clear_widgets (dialog); + + /* Alarm types */ + menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (dialog->action)); + for (i = 0, l = GTK_MENU_SHELL (menu)->children; action_map[i] != -1; i++, l = l->next) { + if (e_cal_get_static_capability (dialog->ecal, action_map_cap[i])) + gtk_widget_set_sensitive (l->data, FALSE); + else + gtk_widget_set_sensitive (l->data, TRUE); + } +} + +/* fill_component handler for the alarm page */ +static void +dialog_to_alarm (Dialog *dialog) +{ + ECalComponentAlarmTrigger trigger; + ECalComponentAlarmAction action; + + memset (&trigger, 0, sizeof (ECalComponentAlarmTrigger)); + trigger.type = e_dialog_option_menu_get (dialog->time, time_map); + if (e_dialog_option_menu_get (dialog->relative, relative_map) == BEFORE) + trigger.u.rel_duration.is_neg = 1; + else + trigger.u.rel_duration.is_neg = 0; + + switch (e_dialog_option_menu_get (dialog->value_units, value_map)) { + case MINUTES: + trigger.u.rel_duration.minutes = + e_dialog_spin_get_int (dialog->interval_value); + break; + + case HOURS: + trigger.u.rel_duration.hours = + e_dialog_spin_get_int (dialog->interval_value); + break; + + case DAYS: + trigger.u.rel_duration.days = + e_dialog_spin_get_int (dialog->interval_value); + break; + + default: + g_assert_not_reached (); + } + e_cal_component_alarm_set_trigger (dialog->alarm, trigger); + + action = e_dialog_option_menu_get (dialog->action, action_map); + e_cal_component_alarm_set_action (dialog->alarm, action); + if (action == E_CAL_COMPONENT_ALARM_EMAIL && !e_cal_component_alarm_has_attendees (dialog->alarm)) { + char *email; + + if (!e_cal_get_static_capability (dialog->ecal, CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS) + && e_cal_get_alarm_email_address (dialog->ecal, &email, NULL)) { + ECalComponentAttendee *a; + GSList attendee_list; + + a = g_new0 (ECalComponentAttendee, 1); + a->value = email; + attendee_list.data = a; + attendee_list.next = NULL; + e_cal_component_alarm_set_attendee_list (dialog->alarm, &attendee_list); + g_free (email); + g_free (a); + } + } +} + +/* Gets the widgets from the XML file and returns TRUE if they are all available. */ +static gboolean +get_widgets (Dialog *dialog) +{ +#define GW(name) glade_xml_get_widget (dialog->xml, name) + + dialog->toplevel = GW ("alarm-dialog"); + if (!dialog->toplevel) + return FALSE; + + dialog->action = GW ("action"); + dialog->interval_value = GW ("interval-value"); + dialog->value_units = GW ("value-units"); + dialog->relative = GW ("relative"); + dialog->time = GW ("time"); + + dialog->button_options = GW ("button-options"); + +#undef GW + + return (dialog->action + && dialog->interval_value + && dialog->value_units + && dialog->relative + && dialog->time + && dialog->button_options); +} + +/* Callback used when the alarm options button is clicked */ +static void +show_options (Dialog *dialog) +{ + gboolean repeat; + char *email; + + e_cal_component_alarm_set_action (dialog->alarm, + e_dialog_option_menu_get (dialog->action, action_map)); + + repeat = !e_cal_get_static_capability (dialog->ecal, CAL_STATIC_CAPABILITY_NO_ALARM_REPEAT); + + if (e_cal_get_static_capability (dialog->ecal, CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS) + || e_cal_get_alarm_email_address (dialog->ecal, &email, NULL)) { + if (!alarm_options_dialog_run (dialog->toplevel, dialog->alarm, email, repeat)) + g_message (G_STRLOC ": not create the alarm options dialog"); + } +} + +/* Hooks the widget signals */ +static void +init_widgets (Dialog *dialog) +{ + +} + +gboolean +alarm_dialog_run (GtkWidget *parent, ECal *ecal, ECalComponentAlarm *alarm) +{ + Dialog dialog; + int response_id; + GList *icon_list; + + g_return_val_if_fail (alarm != NULL, FALSE); + + dialog.alarm = alarm; + dialog.ecal = ecal; + + dialog.xml = glade_xml_new (EVOLUTION_GLADEDIR "/alarm-dialog.glade", NULL, NULL); + if (!dialog.xml) { + g_message (G_STRLOC ": Could not load the Glade XML file!"); + return FALSE; + } + + if (!get_widgets (&dialog)) { + g_object_unref(dialog.xml); + return FALSE; + } + + init_widgets (&dialog); + + alarm_to_dialog (&dialog); + + icon_list = e_icon_factory_get_icon_list ("stock_calendar"); + if (icon_list) { + gtk_window_set_icon_list (GTK_WINDOW (dialog.toplevel), icon_list); + g_list_foreach (icon_list, (GFunc) g_object_unref, NULL); + g_list_free (icon_list); + } + + gtk_window_set_transient_for (GTK_WINDOW (dialog.toplevel), + GTK_WINDOW (parent)); + + keep_alive: + response_id = gtk_dialog_run (GTK_DIALOG (dialog.toplevel)); + switch (response_id) { + case GTK_RESPONSE_APPLY: + show_options (&dialog); + goto keep_alive; + + case GTK_RESPONSE_OK: + gtk_widget_hide (dialog.toplevel); + dialog_to_alarm (&dialog); + break; + + default: + break; + } + + gtk_widget_destroy (dialog.toplevel); + g_object_unref (dialog.xml); + + return response_id == GTK_RESPONSE_OK ? TRUE : FALSE; +} diff --git a/calendar/gui/dialogs/alarm-dialog.glade b/calendar/gui/dialogs/alarm-dialog.glade new file mode 100644 index 0000000000..e95e699453 --- /dev/null +++ b/calendar/gui/dialogs/alarm-dialog.glade @@ -0,0 +1,336 @@ + + + + + + + True + Add Alarm + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_CENTER_ON_PARENT + True + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + True + + + + True + False + 6 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + GTK_RELIEF_NORMAL + True + -10 + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-preferences + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + Options... + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + + + + True + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + True + -6 + + + + + + True + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + True + -5 + + + + + 0 + False + True + GTK_PACK_END + + + + + + True + False + 6 + + + + True + True + 0 + + + + True + + + + True + Pop up an alert + True + + + + + + True + Play a sound + True + + + + + + True + Run a program + True + + + + + + True + Send an email + True + + + + + + + 0 + False + False + + + + + + True + True + 1 + 0 + True + GTK_UPDATE_ALWAYS + False + False + 1 0 999 1 10 10 + + + 0 + False + True + + + + + + True + True + 0 + + + + True + + + + True + minute(s) + True + + + + + + True + hour(s) + True + + + + + + True + day(s) + True + + + + + + + 0 + False + False + + + + + + True + True + 0 + + + + True + + + + True + before + True + + + + + + True + after + True + + + + + + + 0 + False + False + + + + + + True + True + 0 + + + + True + + + + True + start of appointment + True + + + + + + True + end of appointment + True + + + + + + + 0 + False + False + + + + + 0 + False + True + + + + + + + diff --git a/calendar/gui/dialogs/alarm-dialog.h b/calendar/gui/dialogs/alarm-dialog.h new file mode 100644 index 0000000000..8e57579d9f --- /dev/null +++ b/calendar/gui/dialogs/alarm-dialog.h @@ -0,0 +1,37 @@ +/* Evolution calendar - Alarm page of the calendar component dialogs + * + * Copyright (C) 2001-2003 Ximian, Inc. + * + * Authors: Federico Mena-Quintero + * Miguel de Icaza + * Seth Alves + * JP Rosevear + * Hans Petter Jansson + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef ALARM_DIALOG_H +#define ALARM_DIALOG_H + +#include +#include + +G_BEGIN_DECLS + +gboolean alarm_dialog_run (GtkWidget *parent, ECal *ecal, ECalComponentAlarm *alarm); + +G_END_DECLS + +#endif diff --git a/calendar/gui/dialogs/alarm-list-dialog.c b/calendar/gui/dialogs/alarm-list-dialog.c new file mode 100644 index 0000000000..42b992dde7 --- /dev/null +++ b/calendar/gui/dialogs/alarm-list-dialog.c @@ -0,0 +1,244 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ + +/* Evolution calendar - Alarm page of the calendar component dialogs + * + * Copyright (C) 2001-2003 Ximian, Inc. + * + * Authors: Federico Mena-Quintero + * Miguel de Icaza + * Seth Alves + * JP Rosevear + * Hans Petter Jansson + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "e-util/e-dialog-widgets.h" +#include "e-util/e-time-utils.h" +#include +#include +#include "e-util/e-dialog-widgets.h" +#include "e-util/e-icon-factory.h" +#include "alarm-dialog.h" +#include "alarm-list-dialog.h" + + + +typedef struct { + /* Glade XML data */ + GladeXML *xml; + + /* The client */ + ECal *ecal; + + /* The list store */ + EAlarmList *list_store; + + /* Toplevel */ + GtkWidget *toplevel; + + GtkWidget *list; + GtkWidget *add; + GtkWidget *delete; +} Dialog; + +/* Gets the widgets from the XML file and returns TRUE if they are all available. */ +static gboolean +get_widgets (Dialog *dialog) +{ +#define GW(name) glade_xml_get_widget (dialog->xml, name) + + dialog->toplevel = GW ("alarm-list-dialog"); + if (!dialog->toplevel) + return FALSE; + + dialog->list = GW ("list"); + dialog->add = GW ("add"); + dialog->delete = GW ("delete"); + +#undef GW + + return (dialog->list + && dialog->add + && dialog->delete); +} + +static void +sensitize_buttons (Dialog *dialog) +{ + GtkTreeSelection *selection; + GtkTreeIter iter; + gboolean have_selected; + + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->list)); + have_selected = gtk_tree_selection_get_selected (selection, NULL, &iter); + + if (e_cal_get_one_alarm_only (dialog->ecal) && have_selected) + gtk_widget_set_sensitive (dialog->add, FALSE); + else + gtk_widget_set_sensitive (dialog->add, TRUE); + gtk_widget_set_sensitive (dialog->delete, have_selected); +} + +/* Callback used for the "add reminder" button */ +static void +add_clicked_cb (GtkButton *button, gpointer data) +{ + Dialog *dialog = data; + ECalComponentAlarm *alarm; + GtkTreeView *view; + GtkTreeIter iter; + icalcomponent *icalcomp; + icalproperty *icalprop; + + view = GTK_TREE_VIEW (dialog->list); + + alarm = e_cal_component_alarm_new (); + + icalcomp = e_cal_component_alarm_get_icalcomponent (alarm); + icalprop = icalproperty_new_x ("1"); + icalproperty_set_x_name (icalprop, "X-EVOLUTION-NEEDS-DESCRIPTION"); + icalcomponent_add_property (icalcomp, icalprop); + + if (alarm_dialog_run (dialog->toplevel, dialog->ecal, alarm)) { + e_alarm_list_append (dialog->list_store, &iter, alarm); + gtk_tree_selection_select_iter (gtk_tree_view_get_selection (view), &iter); + } else { + e_cal_component_alarm_free (alarm); + } + + sensitize_buttons (dialog); +} + +/* Callback used for the "delete reminder" button */ +static void +delete_clicked_cb (GtkButton *button, gpointer data) +{ + Dialog *dialog = data; + GtkTreeSelection *selection; + GtkTreeIter iter; + GtkTreePath *path; + gboolean valid_iter; + + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->list)); + if (!gtk_tree_selection_get_selected (selection, NULL, &iter)) { + g_warning ("Could not get a selection to delete."); + return; + } + + path = gtk_tree_model_get_path (GTK_TREE_MODEL (dialog->list_store), &iter); + e_alarm_list_remove (dialog->list_store, &iter); + + /* Select closest item after removal */ + valid_iter = gtk_tree_model_get_iter (GTK_TREE_MODEL (dialog->list_store), &iter, path); + if (!valid_iter) { + gtk_tree_path_prev (path); + valid_iter = gtk_tree_model_get_iter (GTK_TREE_MODEL (dialog->list_store), &iter, path); + } + + if (valid_iter) + gtk_tree_selection_select_iter (selection, &iter); + + sensitize_buttons (dialog); + + gtk_tree_path_free (path); +} + +/* Hooks the widget signals */ +static void +init_widgets (Dialog *dialog) +{ + GtkTreeViewColumn *column; + GtkCellRenderer *cell_renderer; + + /* View */ + gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->list), + GTK_TREE_MODEL (dialog->list_store)); + + column = gtk_tree_view_column_new (); + gtk_tree_view_column_set_title (column, _("Action/Trigger")); + cell_renderer = GTK_CELL_RENDERER (gtk_cell_renderer_text_new ()); + gtk_tree_view_column_pack_start (column, cell_renderer, TRUE); + gtk_tree_view_column_add_attribute (column, cell_renderer, "text", E_ALARM_LIST_COLUMN_DESCRIPTION); + gtk_tree_view_append_column (GTK_TREE_VIEW (dialog->list), column); + + /* Reminder buttons */ + g_signal_connect (dialog->add, "clicked", + G_CALLBACK (add_clicked_cb), dialog); + g_signal_connect (dialog->delete, "clicked", + G_CALLBACK (delete_clicked_cb), dialog); +} + +gboolean +alarm_list_dialog_run (GtkWidget *parent, ECal *ecal, EAlarmList *list_store) +{ + Dialog dialog; + int response_id; + GList *icon_list; + + dialog.ecal = ecal; + dialog.list_store = list_store; + + dialog.xml = glade_xml_new (EVOLUTION_GLADEDIR "/alarm-list-dialog.glade", NULL, NULL); + if (!dialog.xml) { + g_message (G_STRLOC ": Could not load the Glade XML file!"); + return FALSE; + } + + if (!get_widgets (&dialog)) { + g_object_unref(dialog.xml); + return FALSE; + } + + init_widgets (&dialog); + + sensitize_buttons (&dialog); + + icon_list = e_icon_factory_get_icon_list ("stock_calendar"); + if (icon_list) { + gtk_window_set_icon_list (GTK_WINDOW (dialog.toplevel), icon_list); + g_list_foreach (icon_list, (GFunc) g_object_unref, NULL); + g_list_free (icon_list); + } + + gtk_window_set_transient_for (GTK_WINDOW (dialog.toplevel), + GTK_WINDOW (parent)); + + response_id = gtk_dialog_run (GTK_DIALOG (dialog.toplevel)); + gtk_widget_hide (dialog.toplevel); + +#if 0 + if (response_id == GTK_RESPONSE_OK) + dialog_to_alarm (&dialog); +#endif + + gtk_widget_destroy (dialog.toplevel); + g_object_unref (dialog.xml); + + return TRUE; +} diff --git a/calendar/gui/dialogs/alarm-list-dialog.glade b/calendar/gui/dialogs/alarm-list-dialog.glade new file mode 100644 index 0000000000..6143b5c6a7 --- /dev/null +++ b/calendar/gui/dialogs/alarm-list-dialog.glade @@ -0,0 +1,219 @@ + + + + + + + True + Alarms + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_CENTER_ON_PARENT + True + 320 + 240 + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + True + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + True + -6 + + + + + + True + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + True + -5 + + + + + 0 + False + True + GTK_PACK_END + + + + + + 6 + True + False + 6 + + + + True + False + 6 + + + + True + GTK_POLICY_NEVER + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + True + False + False + True + + + + + 0 + True + True + + + + + + True + GTK_BUTTONBOX_START + 6 + + + + True + True + True + GTK_RELIEF_NORMAL + True + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-add + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + A_dd + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + + + + + + True + True + True + gtk-remove + True + GTK_RELIEF_NORMAL + True + + + + + 0 + False + False + + + + + 0 + True + True + + + + + 0 + True + True + + + + + + + diff --git a/calendar/gui/dialogs/alarm-list-dialog.h b/calendar/gui/dialogs/alarm-list-dialog.h new file mode 100644 index 0000000000..a46bcccfa4 --- /dev/null +++ b/calendar/gui/dialogs/alarm-list-dialog.h @@ -0,0 +1,38 @@ +/* Evolution calendar - Alarm page of the calendar component dialogs + * + * Copyright (C) 2001-2003 Ximian, Inc. + * + * Authors: Federico Mena-Quintero + * Miguel de Icaza + * Seth Alves + * JP Rosevear + * Hans Petter Jansson + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef ALARM_LIST_DIALOG_H +#define ALARM_LIST_DIALOG_H + +#include +#include +#include "../e-alarm-list.h" + +G_BEGIN_DECLS + +gboolean alarm_list_dialog_run (GtkWidget *parent, ECal *ecal, EAlarmList *list_store); + +G_END_DECLS + +#endif diff --git a/calendar/gui/dialogs/alarm-options.c b/calendar/gui/dialogs/alarm-options.c index 7022325ae3..bb77cb61f4 100644 --- a/calendar/gui/dialogs/alarm-options.c +++ b/calendar/gui/dialogs/alarm-options.c @@ -770,7 +770,7 @@ dialog_to_alarm (Dialog *dialog, ECalComponentAlarm *alarm) * Return value: TRUE if the dialog could be created, FALSE otherwise. **/ gboolean -alarm_options_dialog_run (ECalComponentAlarm *alarm, const char *email, gboolean repeat) +alarm_options_dialog_run (GtkWidget *parent, ECalComponentAlarm *alarm, const char *email, gboolean repeat) { Dialog dialog; int response_id; @@ -782,7 +782,7 @@ alarm_options_dialog_run (ECalComponentAlarm *alarm, const char *email, gboolean dialog.email = email; dialog.xml = glade_xml_new (EVOLUTION_GLADEDIR "/alarm-options.glade", NULL, NULL); if (!dialog.xml) { - g_message ("alarm_options_dialog_new(): Could not load the Glade XML file!"); + g_message (G_STRLOC ": Could not load the Glade XML file!"); return FALSE; } @@ -807,6 +807,9 @@ alarm_options_dialog_run (ECalComponentAlarm *alarm, const char *email, gboolean g_list_free (icon_list); } + gtk_window_set_transient_for (GTK_WINDOW (dialog.toplevel), + GTK_WINDOW (parent)); + response_id = gtk_dialog_run (GTK_DIALOG (dialog.toplevel)); gtk_widget_hide (dialog.toplevel); @@ -818,3 +821,4 @@ alarm_options_dialog_run (ECalComponentAlarm *alarm, const char *email, gboolean return TRUE; } + diff --git a/calendar/gui/dialogs/alarm-options.h b/calendar/gui/dialogs/alarm-options.h index 5a07935810..9811edf253 100644 --- a/calendar/gui/dialogs/alarm-options.h +++ b/calendar/gui/dialogs/alarm-options.h @@ -23,6 +23,6 @@ #include -gboolean alarm_options_dialog_run (ECalComponentAlarm *alarm, const char *email, gboolean repeat); +gboolean alarm_options_dialog_run (GtkWidget *parent, ECalComponentAlarm *alarm, const char *email, gboolean repeat); #endif diff --git a/calendar/gui/dialogs/alarm-page.c b/calendar/gui/dialogs/alarm-page.c deleted file mode 100644 index 8270332707..0000000000 --- a/calendar/gui/dialogs/alarm-page.c +++ /dev/null @@ -1,897 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* Evolution calendar - Alarm page of the calendar component dialogs - * - * Copyright (C) 2001-2003 Ximian, Inc. - * - * Authors: Federico Mena-Quintero - * Miguel de Icaza - * Seth Alves - * JP Rosevear - * Hans Petter Jansson - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "e-util/e-dialog-widgets.h" -#include "e-util/e-time-utils.h" -#include -#include -#include "../calendar-config.h" -#include "comp-editor-util.h" -#include "alarm-options.h" -#include "../e-alarm-list.h" -#include "alarm-page.h" - - - -/* Private part of the AlarmPage structure */ -struct _AlarmPagePrivate { - /* Glade XML data */ - GladeXML *xml; - - /* Widgets from the Glade file */ - - GtkWidget *main; - - GtkWidget *summary; - GtkWidget *date_time; - - GtkWidget *list; - GtkWidget *add; - GtkWidget *delete; - - GtkWidget *action; - GtkWidget *interval_value; - GtkWidget *value_units; - GtkWidget *relative; - GtkWidget *time; - - GtkWidget *button_options; - - /* Alarm options dialog and the alarm we maintain */ - ECalComponentAlarm *alarm; - - /* Alarm store for the GtkTreeView list widget */ - EAlarmList *list_store; - - gboolean updating; - - /* Old summary, to detect changes */ - gchar *old_summary; -}; - -/* "relative" types */ -enum { - BEFORE, - AFTER -}; - -/* Time units */ -enum { - MINUTES, - HOURS, - DAYS -}; - -/* Option menu maps */ -static const int action_map[] = { - E_CAL_COMPONENT_ALARM_DISPLAY, - E_CAL_COMPONENT_ALARM_AUDIO, - E_CAL_COMPONENT_ALARM_PROCEDURE, - E_CAL_COMPONENT_ALARM_EMAIL, - -1 -}; - -static const char *action_map_cap[] = { - CAL_STATIC_CAPABILITY_NO_DISPLAY_ALARMS, - CAL_STATIC_CAPABILITY_NO_AUDIO_ALARMS, - CAL_STATIC_CAPABILITY_NO_PROCEDURE_ALARMS, - CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS -}; - -static const int value_map[] = { - MINUTES, - HOURS, - DAYS, - -1 -}; - -static const int relative_map[] = { - BEFORE, - AFTER, - -1 -}; - -static const int time_map[] = { - E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START, - E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_END, - -1 -}; - - - -static void alarm_page_class_init (AlarmPageClass *class); -static void alarm_page_init (AlarmPage *apage); -static void alarm_page_finalize (GObject *object); - -static GtkWidget *alarm_page_get_widget (CompEditorPage *page); -static void alarm_page_focus_main_widget (CompEditorPage *page); -static gboolean alarm_page_fill_widgets (CompEditorPage *page, ECalComponent *comp); -static gboolean alarm_page_fill_component (CompEditorPage *page, ECalComponent *comp); -static void alarm_page_set_summary (CompEditorPage *page, const char *summary); -static void alarm_page_set_dates (CompEditorPage *page, CompEditorPageDates *dates); - -static CompEditorPageClass *parent_class = NULL; - - - -/** - * alarm_page_get_type: - * - * Registers the #AlarmPage class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the #AlarmPage class. - **/ - -E_MAKE_TYPE (alarm_page, "AlarmPage", AlarmPage, alarm_page_class_init, - alarm_page_init, TYPE_COMP_EDITOR_PAGE); - -/* Class initialization function for the alarm page */ -static void -alarm_page_class_init (AlarmPageClass *class) -{ - CompEditorPageClass *editor_page_class; - GObjectClass *gobject_class; - - editor_page_class = (CompEditorPageClass *) class; - gobject_class = (GObjectClass *) class; - - parent_class = g_type_class_ref (TYPE_COMP_EDITOR_PAGE); - - editor_page_class->get_widget = alarm_page_get_widget; - editor_page_class->focus_main_widget = alarm_page_focus_main_widget; - editor_page_class->fill_widgets = alarm_page_fill_widgets; - editor_page_class->fill_component = alarm_page_fill_component; - editor_page_class->set_summary = alarm_page_set_summary; - editor_page_class->set_dates = alarm_page_set_dates; - - gobject_class->finalize = alarm_page_finalize; -} - -/* Object initialization function for the alarm page */ -static void -alarm_page_init (AlarmPage *apage) -{ - AlarmPagePrivate *priv; - icalcomponent *icalcomp; - icalproperty *icalprop; - - priv = g_new0 (AlarmPagePrivate, 1); - apage->priv = priv; - - priv->xml = NULL; - - priv->main = NULL; - priv->summary = NULL; - priv->date_time = NULL; - priv->list = NULL; - priv->add = NULL; - priv->delete = NULL; - priv->action = NULL; - priv->interval_value = NULL; - priv->value_units = NULL; - priv->relative = NULL; - priv->time = NULL; - priv->button_options = NULL; - - /* create the default alarm, which will contain the - * X-EVOLUTION-NEEDS-DESCRIPTION property, so that we - * set a correct description if none is set */ - priv->alarm = e_cal_component_alarm_new (); - - icalcomp = e_cal_component_alarm_get_icalcomponent (priv->alarm); - icalprop = icalproperty_new_x ("1"); - icalproperty_set_x_name (icalprop, "X-EVOLUTION-NEEDS-DESCRIPTION"); - icalcomponent_add_property (icalcomp, icalprop); - - priv->updating = FALSE; - priv->old_summary = NULL; -} - -/* Destroy handler for the alarm page */ -static void -alarm_page_finalize (GObject *object) -{ - AlarmPage *apage; - AlarmPagePrivate *priv; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_ALARM_PAGE (object)); - - apage = ALARM_PAGE (object); - priv = apage->priv; - - if (priv->main) - gtk_widget_unref (priv->main); - - if (priv->xml) { - g_object_unref (priv->xml); - priv->xml = NULL; - } - - if (priv->alarm) { - e_cal_component_alarm_free (priv->alarm); - priv->alarm = NULL; - } - - if (priv->list_store) { - g_object_unref (priv->list_store); - priv->list_store = NULL; - } - - if (priv->old_summary) { - g_free (priv->old_summary); - priv->old_summary = NULL; - } - - g_free (priv); - apage->priv = NULL; - - if (G_OBJECT_CLASS (parent_class)->finalize) - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - - - -/* get_widget handler for the alarm page */ -static GtkWidget * -alarm_page_get_widget (CompEditorPage *page) -{ - AlarmPage *apage; - AlarmPagePrivate *priv; - - apage = ALARM_PAGE (page); - priv = apage->priv; - - return priv->main; -} - -/* focus_main_widget handler for the alarm page */ -static void -alarm_page_focus_main_widget (CompEditorPage *page) -{ - AlarmPage *apage; - AlarmPagePrivate *priv; - - apage = ALARM_PAGE (page); - priv = apage->priv; - - gtk_widget_grab_focus (priv->action); -} - -/* Fills the widgets with default values */ -static void -clear_widgets (AlarmPage *apage) -{ - AlarmPagePrivate *priv; - - priv = apage->priv; - - /* Summary */ - gtk_label_set_text (GTK_LABEL (priv->summary), ""); - - /* Start date */ - gtk_label_set_text (GTK_LABEL (priv->date_time), ""); - - /* Sane defaults */ - e_dialog_option_menu_set (priv->action, E_CAL_COMPONENT_ALARM_DISPLAY, action_map); - e_dialog_spin_set (priv->interval_value, 15); - e_dialog_option_menu_set (priv->value_units, MINUTES, value_map); - e_dialog_option_menu_set (priv->relative, BEFORE, relative_map); - e_dialog_option_menu_set (priv->time, E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START, time_map); - - /* List data */ - e_alarm_list_clear (priv->list_store); -} - -static void -sensitize_buttons (AlarmPage *apage) -{ - AlarmPagePrivate *priv; - ECal *client; - GtkTreeSelection *selection; - GtkTreeIter iter; - gboolean have_selected, read_only, sensitivity; - - priv = apage->priv; - - client = COMP_EDITOR_PAGE (apage)->client; - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->list)); - have_selected = gtk_tree_selection_get_selected (selection, NULL, &iter); - - if (e_cal_is_read_only (COMP_EDITOR_PAGE (apage)->client, &read_only, NULL) && read_only) - sensitivity = FALSE; - else - sensitivity = TRUE; - - if (e_cal_get_one_alarm_only (COMP_EDITOR_PAGE (apage)->client) && have_selected) - gtk_widget_set_sensitive (apage->priv->add, FALSE); - else - gtk_widget_set_sensitive (apage->priv->add, sensitivity); - gtk_widget_set_sensitive (priv->delete, have_selected && !read_only ? TRUE : FALSE); - gtk_widget_set_sensitive (priv->action, sensitivity); - gtk_widget_set_sensitive (priv->interval_value, sensitivity); - gtk_widget_set_sensitive (priv->value_units, sensitivity); - gtk_widget_set_sensitive (priv->relative, sensitivity); - gtk_widget_set_sensitive (priv->time, sensitivity); - gtk_widget_set_sensitive (priv->button_options, sensitivity); -} - -/* Appends an alarm to the list */ -static void -append_reminder (AlarmPage *apage, ECalComponentAlarm *alarm) -{ - AlarmPagePrivate *priv; - GtkTreeView *view; - GtkTreeIter iter; - - priv = apage->priv; - view = GTK_TREE_VIEW (priv->list); - - e_alarm_list_append (priv->list_store, &iter, alarm); - gtk_tree_selection_select_iter (gtk_tree_view_get_selection (view), &iter); - - sensitize_buttons (apage); -} - -/* fill_widgets handler for the alarm page */ -static gboolean -alarm_page_fill_widgets (CompEditorPage *page, ECalComponent *comp) -{ - AlarmPage *apage; - AlarmPagePrivate *priv; - GtkWidget *menu; - ECalComponentText text; - GList *alarms, *l; - CompEditorPageDates dates; - int i; - - apage = ALARM_PAGE (page); - priv = apage->priv; - - /* Don't send off changes during this time */ - priv->updating = TRUE; - - /* Clean the page */ - clear_widgets (apage); - - /* Summary */ - e_cal_component_get_summary (comp, &text); - alarm_page_set_summary (page, text.value); - - /* Dates */ - comp_editor_dates (&dates, comp); - alarm_page_set_dates (page, &dates); - comp_editor_free_dates (&dates); - - /* List */ - if (!e_cal_component_has_alarms (comp)) - goto out; - - alarms = e_cal_component_get_alarm_uids (comp); - - for (l = alarms; l != NULL; l = l->next) { - ECalComponentAlarm *ca, *ca_copy; - const char *auid; - - auid = l->data; - ca = e_cal_component_get_alarm (comp, auid); - g_assert (ca != NULL); - - ca_copy = e_cal_component_alarm_clone (ca); - e_cal_component_alarm_free (ca); - - append_reminder (apage, ca_copy); - } - cal_obj_uid_list_free (alarms); - - out: - - /* Alarm types */ - menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (priv->action)); - for (i = 0, l = GTK_MENU_SHELL (menu)->children; action_map[i] != -1; i++, l = l->next) { - if (e_cal_get_static_capability (page->client, action_map_cap[i])) - gtk_widget_set_sensitive (l->data, FALSE); - else - gtk_widget_set_sensitive (l->data, TRUE); - } - - sensitize_buttons (apage); - - priv->updating = FALSE; - - return TRUE; -} - -/* fill_component handler for the alarm page */ -static gboolean -alarm_page_fill_component (CompEditorPage *page, ECalComponent *comp) -{ - AlarmPage *apage; - AlarmPagePrivate *priv; - GtkTreeView *view; - GtkTreeModel *model; - GtkTreeIter iter; - gboolean valid_iter; - GList *list, *l; - - apage = ALARM_PAGE (page); - priv = apage->priv; - - /* Remove all the alarms from the component */ - - list = e_cal_component_get_alarm_uids (comp); - for (l = list; l; l = l->next) { - const char *auid; - - auid = l->data; - e_cal_component_remove_alarm (comp, auid); - } - cal_obj_uid_list_free (list); - - /* Add the new alarms */ - - view = GTK_TREE_VIEW (priv->list); - model = GTK_TREE_MODEL (priv->list_store); - - for (valid_iter = gtk_tree_model_get_iter_first (model, &iter); valid_iter; - valid_iter = gtk_tree_model_iter_next (model, &iter)) { - ECalComponentAlarm *alarm, *alarm_copy; - icalcomponent *icalcomp; - icalproperty *icalprop; - - alarm = (ECalComponentAlarm *) e_alarm_list_get_alarm (priv->list_store, &iter); - g_assert (alarm != NULL); - - /* We set the description of the alarm if it's got - * the X-EVOLUTION-NEEDS-DESCRIPTION property. - */ - icalcomp = e_cal_component_alarm_get_icalcomponent (alarm); - icalprop = icalcomponent_get_first_property (icalcomp, ICAL_X_PROPERTY); - while (icalprop) { - const char *x_name; - ECalComponentText summary; - - x_name = icalproperty_get_x_name (icalprop); - if (!strcmp (x_name, "X-EVOLUTION-NEEDS-DESCRIPTION")) { - e_cal_component_get_summary (comp, &summary); - e_cal_component_alarm_set_description (alarm, &summary); - - icalcomponent_remove_property (icalcomp, icalprop); - break; - } - - icalprop = icalcomponent_get_next_property (icalcomp, ICAL_X_PROPERTY); - } - - /* We clone the alarm to maintain the invariant that the alarm - * structures in the list did *not* come from the component. - */ - - alarm_copy = e_cal_component_alarm_clone (alarm); - e_cal_component_add_alarm (comp, alarm_copy); - e_cal_component_alarm_free (alarm_copy); - } - - return TRUE; -} - -/* set_summary handler for the alarm page */ -static void -alarm_page_set_summary (CompEditorPage *page, const char *summary) -{ - AlarmPage *apage; - AlarmPagePrivate *priv; - - apage = ALARM_PAGE (page); - priv = apage->priv; - - gtk_label_set_text (GTK_LABEL (priv->summary), summary); - - /* iterate over all alarms */ - if (priv->old_summary) { - GtkTreeView *view; - GtkTreeModel *model; - GtkTreeIter iter; - gboolean valid_iter; - - view = GTK_TREE_VIEW (priv->list); - model = GTK_TREE_MODEL (priv->list_store); - - for (valid_iter = gtk_tree_model_get_iter_first (model, &iter); valid_iter; - valid_iter = gtk_tree_model_iter_next (model, &iter)) { - ECalComponentAlarm *alarm; - ECalComponentText desc; - - alarm = (ECalComponentAlarm *) e_alarm_list_get_alarm (priv->list_store, &iter); - g_assert (alarm != NULL); - - e_cal_component_alarm_get_description (alarm, &desc); - if (desc.value && *desc.value) { - if (!strcmp (desc.value, priv->old_summary)) { - desc.value = summary; - e_cal_component_alarm_set_description (alarm, &desc); - } - } - } - - g_free (priv->old_summary); - } - - /* update old summary */ - priv->old_summary = g_strdup (summary); -} - -/* set_dates handler for the alarm page */ -static void -alarm_page_set_dates (CompEditorPage *page, CompEditorPageDates *dates) -{ - AlarmPage *apage; - AlarmPagePrivate *priv; - - apage = ALARM_PAGE (page); - priv = apage->priv; - - comp_editor_date_label (dates, priv->date_time); -} - - - -/* Gets the widgets from the XML file and returns TRUE if they are all available. */ -static gboolean -get_widgets (AlarmPage *apage) -{ - CompEditorPage *page = COMP_EDITOR_PAGE (apage); - AlarmPagePrivate *priv; - GSList *accel_groups; - GtkWidget *toplevel; - - priv = apage->priv; - -#define GW(name) glade_xml_get_widget (priv->xml, name) - - priv->main = GW ("alarm-page"); - if (!priv->main) - return FALSE; - - /* Get the GtkAccelGroup from the toplevel window, so we can install - it when the notebook page is mapped. */ - toplevel = gtk_widget_get_toplevel (priv->main); - accel_groups = gtk_accel_groups_from_object (G_OBJECT (toplevel)); - if (accel_groups) { - page->accel_group = accel_groups->data; - gtk_accel_group_ref (page->accel_group); - } - - gtk_widget_ref (priv->main); - gtk_container_remove (GTK_CONTAINER (priv->main->parent), priv->main); - - priv->summary = GW ("summary"); - priv->date_time = GW ("date-time"); - - priv->list = GW ("list"); - priv->add = GW ("add"); - priv->delete = GW ("delete"); - - priv->action = GW ("action"); - priv->interval_value = GW ("interval-value"); - priv->value_units = GW ("value-units"); - priv->relative = GW ("relative"); - priv->time = GW ("time"); - - priv->button_options = GW ("button-options"); - -#undef GW - - return (priv->summary - && priv->date_time - && priv->list - && priv->add - && priv->delete - && priv->action - && priv->interval_value - && priv->value_units - && priv->relative - && priv->time - && priv->button_options); -} - -/* This is called when any field is changed; it notifies upstream. */ -static void -field_changed_cb (GtkWidget *widget, gpointer data) -{ - AlarmPage *apage; - AlarmPagePrivate *priv; - - apage = ALARM_PAGE (data); - priv = apage->priv; - - if (!priv->updating) - comp_editor_page_notify_changed (COMP_EDITOR_PAGE (apage)); -} - -/* Callback used for the "add reminder" button */ -static void -add_clicked_cb (GtkButton *button, gpointer data) -{ - AlarmPage *apage; - AlarmPagePrivate *priv; - ECalComponentAlarm *alarm; - ECalComponentAlarmTrigger trigger; - ECalComponentAlarmAction action; - - apage = ALARM_PAGE (data); - priv = apage->priv; - - alarm = e_cal_component_alarm_clone (priv->alarm); - - memset (&trigger, 0, sizeof (ECalComponentAlarmTrigger)); - trigger.type = e_dialog_option_menu_get (priv->time, time_map); - if (e_dialog_option_menu_get (priv->relative, relative_map) == BEFORE) - trigger.u.rel_duration.is_neg = 1; - else - trigger.u.rel_duration.is_neg = 0; - - switch (e_dialog_option_menu_get (priv->value_units, value_map)) { - case MINUTES: - trigger.u.rel_duration.minutes = - e_dialog_spin_get_int (priv->interval_value); - break; - - case HOURS: - trigger.u.rel_duration.hours = - e_dialog_spin_get_int (priv->interval_value); - break; - - case DAYS: - trigger.u.rel_duration.days = - e_dialog_spin_get_int (priv->interval_value); - break; - - default: - g_assert_not_reached (); - } - e_cal_component_alarm_set_trigger (alarm, trigger); - - action = e_dialog_option_menu_get (priv->action, action_map); - e_cal_component_alarm_set_action (alarm, action); - if (action == E_CAL_COMPONENT_ALARM_EMAIL && !e_cal_component_alarm_has_attendees (alarm)) { - char *email; - - if (!e_cal_get_static_capability (COMP_EDITOR_PAGE (apage)->client, CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS) - && e_cal_get_alarm_email_address (COMP_EDITOR_PAGE (apage)->client, &email, NULL)) { - ECalComponentAttendee *a; - GSList attendee_list; - - a = g_new0 (ECalComponentAttendee, 1); - a->value = email; - attendee_list.data = a; - attendee_list.next = NULL; - e_cal_component_alarm_set_attendee_list (alarm, &attendee_list); - g_free (email); - g_free (a); - } - } - - append_reminder (apage, alarm); -} - -/* Callback used for the "delete reminder" button */ -static void -delete_clicked_cb (GtkButton *button, gpointer data) -{ - AlarmPage *apage; - AlarmPagePrivate *priv; - GtkTreeSelection *selection; - GtkTreeIter iter; - GtkTreePath *path; - gboolean valid_iter; - - apage = ALARM_PAGE (data); - priv = apage->priv; - - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->list)); - if (!gtk_tree_selection_get_selected (selection, NULL, &iter)) { - g_warning ("Could not get a selection to delete."); - return; - } - - path = gtk_tree_model_get_path (GTK_TREE_MODEL (priv->list_store), &iter); - e_alarm_list_remove (priv->list_store, &iter); - - /* Select closest item after removal */ - valid_iter = gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->list_store), &iter, path); - if (!valid_iter) { - gtk_tree_path_prev (path); - valid_iter = gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->list_store), &iter, path); - } - - if (valid_iter) - gtk_tree_selection_select_iter (selection, &iter); - - sensitize_buttons (apage); - - gtk_tree_path_free (path); -} - -/* Callback used when the alarm options button is clicked */ -static void -button_options_clicked_cb (GtkWidget *widget, gpointer data) -{ - AlarmPage *apage; - AlarmPagePrivate *priv; - gboolean repeat; - char *email; - - apage = ALARM_PAGE (data); - priv = apage->priv; - - e_cal_component_alarm_set_action (priv->alarm, - e_dialog_option_menu_get (priv->action, action_map)); - - repeat = !e_cal_get_static_capability (COMP_EDITOR_PAGE (apage)->client, - CAL_STATIC_CAPABILITY_NO_ALARM_REPEAT); - - if (e_cal_get_static_capability (COMP_EDITOR_PAGE (apage)->client, CAL_STATIC_CAPABILITY_NO_EMAIL_ALARMS) - || e_cal_get_alarm_email_address (COMP_EDITOR_PAGE (apage)->client, &email, NULL)) { - if (!alarm_options_dialog_run (priv->alarm, email, repeat)) - g_message ("button_options_clicked_cb(): Could not create the alarm options dialog"); - } -} - -/* Hooks the widget signals */ -static void -init_widgets (AlarmPage *apage) -{ - AlarmPagePrivate *priv; - GtkTreeViewColumn *column; - GtkCellRenderer *cell_renderer; - - priv = apage->priv; - - /* Reminder buttons */ - g_signal_connect ((priv->add), "clicked", - G_CALLBACK (add_clicked_cb), apage); - g_signal_connect ((priv->delete), "clicked", - G_CALLBACK (delete_clicked_cb), apage); - - /* Connect the default signal handler to use to make sure we notify - * upstream of changes to the widget values. - */ - g_signal_connect ((priv->add), "clicked", - G_CALLBACK (field_changed_cb), apage); - g_signal_connect ((priv->delete), "clicked", - G_CALLBACK (field_changed_cb), apage); - - /* Options button */ - g_signal_connect ((priv->button_options), "clicked", - G_CALLBACK (button_options_clicked_cb), apage); - - /* Alarm list */ - - /* Model */ - priv->list_store = e_alarm_list_new (); - gtk_tree_view_set_model (GTK_TREE_VIEW (priv->list), - GTK_TREE_MODEL (priv->list_store)); - - /* View */ - column = gtk_tree_view_column_new (); - gtk_tree_view_column_set_title (column, _("Action/Trigger")); - cell_renderer = GTK_CELL_RENDERER (gtk_cell_renderer_text_new ()); - gtk_tree_view_column_pack_start (column, cell_renderer, TRUE); - gtk_tree_view_column_add_attribute (column, cell_renderer, "text", E_ALARM_LIST_COLUMN_DESCRIPTION); - gtk_tree_view_append_column (GTK_TREE_VIEW (priv->list), column); - -#if 0 - /* If we want the alarm setup widgets to reflect the currently selected alarm, we - * need to do something like this */ - g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->list)), "changed", - G_CALLBACK (alarm_selection_changed_cb), apage); -#endif -} - - - -static void -client_changed_cb (CompEditorPage *page, ECal *client, gpointer user_data) -{ - AlarmPage *apage = ALARM_PAGE (page); - - sensitize_buttons (apage); -} - -/** - * alarm_page_construct: - * @apage: An alarm page. - * - * Constructs an alarm page by loading its Glade data. - * - * Return value: The same object as @apage, or NULL if the widgets could not be - * created. - **/ -AlarmPage * -alarm_page_construct (AlarmPage *apage) -{ - AlarmPagePrivate *priv; - - priv = apage->priv; - - priv->xml = glade_xml_new (EVOLUTION_GLADEDIR "/alarm-page.glade", - NULL, NULL); - if (!priv->xml) { - g_message ("alarm_page_construct(): " - "Could not load the Glade XML file!"); - return NULL; - } - - if (!get_widgets (apage)) { - g_message ("alarm_page_construct(): " - "Could not find all widgets in the XML file!"); - return NULL; - } - - init_widgets (apage); - - g_signal_connect_after (G_OBJECT (apage), "client_changed", - G_CALLBACK (client_changed_cb), NULL); - - return apage; -} - -/** - * alarm_page_new: - * - * Creates a new alarm page. - * - * Return value: A newly-created alarm page, or NULL if the page could not be - * created. - **/ -AlarmPage * -alarm_page_new (void) -{ - AlarmPage *apage; - - apage = g_object_new (TYPE_ALARM_PAGE, NULL); - if (!alarm_page_construct (apage)) { - g_object_unref (apage); - return NULL; - } - - return apage; -} diff --git a/calendar/gui/dialogs/alarm-page.glade b/calendar/gui/dialogs/alarm-page.glade deleted file mode 100644 index c1a89727c7..0000000000 --- a/calendar/gui/dialogs/alarm-page.glade +++ /dev/null @@ -1,545 +0,0 @@ - - - - - - - - window1 - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - True - False - - - - 12 - True - False - 6 - - - - True - 0 - 0.5 - GTK_SHADOW_ETCHED_IN - - - - 6 - True - 2 - 2 - False - 6 - 6 - - - - True - Summary: - False - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 0 - 1 - fill - - - - - - - True - Date/Time: - False - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0 - 0 - 0 - - - 0 - 1 - 1 - 2 - fill - fill - - - - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 4 - 0 - - - 1 - 2 - 0 - 1 - - - - - - - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 7.45058e-09 - 0.5 - 4 - 0 - - - 1 - 2 - 1 - 2 - fill - - - - - - - - True - Basics - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - label_item - - - - - 0 - False - True - - - - - - True - 0 - 0.5 - GTK_SHADOW_ETCHED_IN - - - - 6 - True - False - 6 - - - - True - False - 6 - - - - True - True - 0 - - - - True - - - - True - Pop up an alert - True - - - - - - True - Play a sound - True - - - - - - True - Run a program - True - - - - - - True - Send an email - True - - - - - - - 0 - False - False - - - - - - True - True - 1 - 0 - True - GTK_UPDATE_ALWAYS - False - False - 1 0 999 1 10 10 - - - 0 - False - True - - - - - - True - True - 0 - - - - True - - - - True - minute(s) - True - - - - - - True - hour(s) - True - - - - - - True - day(s) - True - - - - - - - 0 - False - False - - - - - - True - True - 0 - - - - True - - - - True - before - True - - - - - - True - after - True - - - - - - - 0 - False - False - - - - - - True - True - 0 - - - - True - - - - True - start of appointment - True - - - - - - True - end of appointment - True - - - - - - - 0 - False - False - - - - - - True - True - _Options... - True - GTK_RELIEF_NORMAL - - - 0 - False - False - - - - - 0 - False - True - - - - - - True - False - 6 - - - - True - GTK_POLICY_NEVER - GTK_POLICY_AUTOMATIC - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT - - - - True - True - True - False - False - True - - - - - 0 - True - True - - - - - - True - GTK_BUTTONBOX_START - 6 - - - - True - True - True - GTK_RELIEF_NORMAL - - - - True - 0.5 - 0.5 - 0 - 0 - - - - True - False - 2 - - - - True - gtk-add - 4 - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - A_dd - True - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - - - - - - - True - True - True - gtk-remove - True - GTK_RELIEF_NORMAL - - - - - 0 - False - False - - - - - 0 - True - True - - - - - - - - True - Reminders - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - label_item - - - - - 0 - True - True - - - - - - - diff --git a/calendar/gui/dialogs/alarm-page.h b/calendar/gui/dialogs/alarm-page.h deleted file mode 100644 index d814e850b3..0000000000 --- a/calendar/gui/dialogs/alarm-page.h +++ /dev/null @@ -1,62 +0,0 @@ -/* Evolution calendar - Alarm page of the calendar component dialogs - * - * Copyright (C) 2001-2003 Ximian, Inc. - * - * Authors: Federico Mena-Quintero - * Miguel de Icaza - * Seth Alves - * JP Rosevear - * Hans Petter Jansson - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef ALARM_PAGE_H -#define ALARM_PAGE_H - -#include "comp-editor-page.h" - -G_BEGIN_DECLS - - - -#define TYPE_ALARM_PAGE (alarm_page_get_type ()) -#define ALARM_PAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_ALARM_PAGE, AlarmPage)) -#define ALARM_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_ALARM_PAGE, AlarmPageClass)) -#define IS_ALARM_PAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_ALARM_PAGE)) -#define IS_ALARM_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), TYPE_ALARM_PAGE)) - -typedef struct _AlarmPagePrivate AlarmPagePrivate; - -typedef struct { - CompEditorPage page; - - /* Private data */ - AlarmPagePrivate *priv; -} AlarmPage; - -typedef struct { - CompEditorPageClass parent_class; -} AlarmPageClass; - - -GtkType alarm_page_get_type (void); -AlarmPage *alarm_page_construct (AlarmPage *apage); -AlarmPage *alarm_page_new (void); - - - -G_END_DECLS - -#endif diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c index 9dcbf1d80a..16d89055c2 100644 --- a/calendar/gui/dialogs/comp-editor.c +++ b/calendar/gui/dialogs/comp-editor.c @@ -34,8 +34,6 @@ #include #include #include -#include -#include #include #include #include @@ -68,14 +66,9 @@ struct _CompEditorPrivate { /* The pages we have */ GList *pages; - /* UI Component for the dialog */ - BonoboUIComponent *uic; - /* Notebook to hold the pages */ GtkNotebook *notebook; - - GtkWidget *filesel; - + gboolean changed; gboolean needs_send; @@ -119,42 +112,12 @@ static void close_cmd (GtkWidget *widget, gpointer data); static gint delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data); -static EPixmap pixmaps [] = -{ - E_PIXMAP ("/menu/File/FileSave", "stock_save", E_ICON_SIZE_MENU), - E_PIXMAP ("/menu/File/FileSaveAndClose", "stock_save", E_ICON_SIZE_MENU), - E_PIXMAP ("/menu/File/FileSaveAs", "stock_save-as", E_ICON_SIZE_MENU), - - E_PIXMAP ("/menu/File/FileDelete", "stock_delete", E_ICON_SIZE_MENU), - - E_PIXMAP ("/menu/File/FilePrint", "stock_print", E_ICON_SIZE_MENU), - E_PIXMAP ("/menu/File/FilePrintPreview", "stock_print-preview", E_ICON_SIZE_MENU), - - E_PIXMAP ("/Toolbar/FileSaveAndClose", "stock_save", E_ICON_SIZE_LARGE_TOOLBAR), - E_PIXMAP ("/Toolbar/FilePrint", "stock_print", E_ICON_SIZE_LARGE_TOOLBAR), - E_PIXMAP ("/Toolbar/FileDelete", "stock_delete", E_ICON_SIZE_LARGE_TOOLBAR), - - E_PIXMAP_END -}; - -static BonoboUIVerb verbs [] = { - BONOBO_UI_UNSAFE_VERB ("FileSaveAndClose", save_close_cmd), - BONOBO_UI_UNSAFE_VERB ("FileSaveAs", save_as_cmd), - BONOBO_UI_UNSAFE_VERB ("FileDelete", delete_cmd), - BONOBO_UI_UNSAFE_VERB ("FilePrint", print_cmd), - BONOBO_UI_UNSAFE_VERB ("FilePrintPreview", print_preview_cmd), - BONOBO_UI_UNSAFE_VERB ("FilePrintSetup", print_setup_cmd), - BONOBO_UI_UNSAFE_VERB ("FileClose", close_cmd), - - BONOBO_UI_VERB_END -}; - static GtkObjectClass *parent_class; E_MAKE_TYPE (comp_editor, "CompEditor", CompEditor, comp_editor_class_init, comp_editor_init, - BONOBO_TYPE_WINDOW); + GTK_TYPE_DIALOG); /* Class initialization function for the calendar component editor */ static void @@ -163,11 +126,10 @@ comp_editor_class_init (CompEditorClass *klass) GObjectClass *object_class; GtkWidgetClass *widget_class; + parent_class = g_type_class_peek_parent (klass); object_class = G_OBJECT_CLASS (klass); widget_class = GTK_WIDGET_CLASS (klass); - parent_class = g_type_class_ref(BONOBO_TYPE_WINDOW); - klass->set_e_cal = real_set_e_cal; klass->edit_comp = real_edit_comp; klass->send_comp = real_send_comp; @@ -176,135 +138,6 @@ comp_editor_class_init (CompEditorClass *klass) object_class->finalize = comp_editor_finalize; } -/* Creates the basic in the editor */ -static void -setup_widgets (CompEditor *editor) -{ - CompEditorPrivate *priv; - BonoboUIContainer *container; - GtkWidget *vbox; - - priv = editor->priv; - - /* Window and basic vbox */ - container = bonobo_ui_container_new (); - editor = (CompEditor *) bonobo_window_construct (BONOBO_WINDOW (editor), container, - "event-editor", "iCalendar Editor"); - g_signal_connect((editor), "delete_event", - G_CALLBACK (delete_event_cb), editor); - - priv->uic = bonobo_ui_component_new_default (); - bonobo_ui_component_set_container (priv->uic, - bonobo_object_corba_objref (BONOBO_OBJECT (container)), - NULL); - bonobo_ui_engine_config_set_path (bonobo_window_get_ui_engine (BONOBO_WINDOW (editor)), - "/evolution/UIConf/kvps"); - - bonobo_ui_component_add_verb_list_with_data (priv->uic, verbs, editor); - bonobo_ui_util_set_ui (priv->uic, PREFIX, - EVOLUTION_UIDIR "/evolution-comp-editor.xml", - "evolution-calendar", NULL); - e_pixmaps_update (priv->uic, pixmaps); - - vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL); - gtk_widget_show (vbox); - gtk_container_set_border_width (GTK_CONTAINER (vbox), GNOME_PAD_SMALL); - bonobo_window_set_contents (BONOBO_WINDOW (editor), 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, 6); -} - -/* Object initialization function for the calendar component editor */ -static void -comp_editor_init (CompEditor *editor) -{ - CompEditorPrivate *priv; - - priv = g_new0 (CompEditorPrivate, 1); - editor->priv = priv; - - setup_widgets (editor); - - priv->pages = NULL; - priv->changed = FALSE; - priv->needs_send = FALSE; - priv->mod = CALOBJ_MOD_ALL; - priv->existing_org = FALSE; - priv->user_org = FALSE; - priv->warned = FALSE; -} - - -static gint -comp_editor_key_press_event (GtkWidget *d, GdkEventKey *e) -{ - if (e->keyval == GDK_Escape) { - if (prompt_to_save_changes (COMP_EDITOR (d), TRUE)) - close_dialog (COMP_EDITOR (d)); - return TRUE; - } - - if (GTK_WIDGET_CLASS (parent_class)->key_press_event) - return (* GTK_WIDGET_CLASS (parent_class)->key_press_event) (d, e); - - return FALSE; -} - -/* Destroy handler for the calendar component editor */ -static void -comp_editor_finalize (GObject *object) -{ - CompEditor *editor; - CompEditorPrivate *priv; - GList *l; - - editor = COMP_EDITOR (object); - priv = editor->priv; - - if (priv->client) { - g_object_unref (priv->client); - priv->client = NULL; - } - - if (priv->source_client) { - g_object_unref (priv->source_client); - priv->source_client = NULL; - } - - if (priv->view) { - g_signal_handlers_disconnect_matched (G_OBJECT (priv->view), - G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, - editor); - - g_object_unref (priv->view); - priv->view = NULL; - } - - /* We want to destroy the pages after the widgets get destroyed, - since they have lots of signal handlers connected to the widgets - with the pages as the data. */ - for (l = priv->pages; l != NULL; l = l->next) - g_object_unref (l->data); - - if (priv->comp) { - g_object_unref (priv->comp); - priv->comp = NULL; - } - - bonobo_object_unref (priv->uic); - - g_free (priv); - editor->priv = NULL; - - if (G_OBJECT_CLASS (parent_class)->finalize) - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - static void listen_for_changes (CompEditor *editor) { @@ -332,7 +165,6 @@ listen_for_changes (CompEditor *editor) char *query; query = g_strdup_printf ("(uid? \"%s\")", uid); - g_message ("%s", query); e_cal_get_query (priv->source_client, query, &priv->view, NULL); g_free (query); } @@ -348,6 +180,19 @@ listen_for_changes (CompEditor *editor) } } +/* This sets the focus to the toplevel, so any field being edited is committed. + FIXME: In future we may also want to check some of the fields are valid, + e.g. the EDateEdit fields. */ +static void +commit_all_fields (CompEditor *editor) +{ + CompEditorPrivate *priv; + + priv = editor->priv; + + gtk_window_set_focus (GTK_WINDOW (editor), NULL); +} + static void send_timezone (gpointer key, gpointer value, gpointer user_data) { @@ -481,19 +326,6 @@ save_comp_with_send (CompEditor *editor) return TRUE; } -static void -delete_comp (CompEditor *editor) -{ - CompEditorPrivate *priv; - const char *uid; - - priv = editor->priv; - - e_cal_component_get_uid (priv->comp, &uid); - e_cal_remove_object (priv->client, uid, NULL); - close_dialog (editor); -} - static gboolean prompt_to_save_changes (CompEditor *editor, gboolean send) { @@ -528,17 +360,164 @@ prompt_to_save_changes (CompEditor *editor, gboolean send) } } -/* This sets the focus to the toplevel, so any field being edited is committed. - FIXME: In future we may also want to check some of the fields are valid, - e.g. the EDateEdit fields. */ static void -commit_all_fields (CompEditor *editor) +response_cb (GtkWidget *widget, int response, gpointer data) { + CompEditor *editor = COMP_EDITOR (data); CompEditorPrivate *priv; + + priv = editor->priv; + + switch (response) { + case GTK_RESPONSE_OK: + commit_all_fields (editor); + + 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)) + close_dialog (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; + } +} + +/* Creates the basic in the editor */ +static void +setup_widgets (CompEditor *editor) +{ + CompEditorPrivate *priv; + GtkWidget *vbox; priv = editor->priv; - gtk_window_set_focus (GTK_WINDOW (editor), NULL); + /* Basic vbox */ + vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL); + gtk_widget_show (vbox); + gtk_container_set_border_width (GTK_CONTAINER (vbox), GNOME_PAD_SMALL); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (editor)->vbox), vbox, + TRUE, TRUE, 6); + + /* 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, 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_set_response_sensitive (GTK_DIALOG (editor), GTK_RESPONSE_OK, FALSE); + + g_signal_connect (editor, "response", G_CALLBACK (response_cb), editor); +} + +/* Object initialization function for the calendar component editor */ +static void +comp_editor_init (CompEditor *editor) +{ + CompEditorPrivate *priv; + + priv = g_new0 (CompEditorPrivate, 1); + editor->priv = priv; + + setup_widgets (editor); + + priv->pages = NULL; + priv->changed = FALSE; + priv->needs_send = FALSE; + priv->mod = CALOBJ_MOD_ALL; + priv->existing_org = FALSE; + priv->user_org = FALSE; + priv->warned = FALSE; +} + + +static gint +comp_editor_key_press_event (GtkWidget *d, GdkEventKey *e) +{ +#if 0 + if (e->keyval == GDK_Escape) { + if (prompt_to_save_changes (COMP_EDITOR (d), TRUE)) + close_dialog (COMP_EDITOR (d)); + return TRUE; + } +#endif + + if (GTK_WIDGET_CLASS (parent_class)->key_press_event) + return (* GTK_WIDGET_CLASS (parent_class)->key_press_event) (d, e); + + return FALSE; +} + +/* Destroy handler for the calendar component editor */ +static void +comp_editor_finalize (GObject *object) +{ + CompEditor *editor; + CompEditorPrivate *priv; + GList *l; + + editor = COMP_EDITOR (object); + priv = editor->priv; + + if (priv->client) { + g_object_unref (priv->client); + priv->client = NULL; + } + + if (priv->source_client) { + g_object_unref (priv->source_client); + priv->source_client = NULL; + } + + if (priv->view) { + g_signal_handlers_disconnect_matched (G_OBJECT (priv->view), + G_SIGNAL_MATCH_DATA, + 0, 0, NULL, NULL, + editor); + + g_object_unref (priv->view); + priv->view = NULL; + } + + /* We want to destroy the pages after the widgets get destroyed, + since they have lots of signal handlers connected to the widgets + with the pages as the data. */ + for (l = priv->pages; l != NULL; l = l->next) + g_object_unref (l->data); + + if (priv->comp) { + g_object_unref (priv->comp); + priv->comp = NULL; + } + + g_free (priv); + editor->priv = NULL; + + if (G_OBJECT_CLASS (parent_class)->finalize) + (* G_OBJECT_CLASS (parent_class)->finalize) (object); +} + + +static void +delete_comp (CompEditor *editor) +{ + CompEditorPrivate *priv; + const char *uid; + + priv = editor->priv; + + e_cal_component_get_uid (priv->comp, &uid); + e_cal_remove_object (priv->client, uid, NULL); + close_dialog (editor); } /* Closes the dialog box and emits the appropriate signals */ @@ -629,6 +608,9 @@ comp_editor_set_changed (CompEditor *editor, gboolean changed) priv = editor->priv; priv->changed = changed; + + gtk_dialog_set_response_sensitive (GTK_DIALOG (editor), GTK_RESPONSE_OK, changed); + gtk_dialog_set_default_response (GTK_DIALOG (editor), GTK_RESPONSE_OK); } /** @@ -1254,65 +1236,6 @@ comp_editor_close (CompEditor *editor) return close; } -/** - * comp_editor_merge_ui: - * @editor: - * @filename: - * @verbs: - * - * - **/ -void -comp_editor_merge_ui (CompEditor *editor, - const char *filename, - BonoboUIVerb *verbs, - EPixmap *component_pixmaps) -{ - CompEditorPrivate *priv; - char *path; - - g_return_if_fail (editor != NULL); - g_return_if_fail (IS_COMP_EDITOR (editor)); - - priv = editor->priv; - - path = g_strconcat (EVOLUTION_UIDIR "/", filename, NULL); - - bonobo_ui_util_set_ui (priv->uic, EVOLUTION_DATADIR, path, "evolution-calendar", NULL); - bonobo_ui_component_add_verb_list_with_data (priv->uic, verbs, editor); - - g_free (path); - - if (component_pixmaps != NULL) - e_pixmaps_update (priv->uic, component_pixmaps); -} - -/** - * comp_editor_set_ui_prop: - * @editor: - * @path: - * @attr: - * @val: - * - * - **/ -void -comp_editor_set_ui_prop (CompEditor *editor, - const char *path, - const char *attr, - const char *val) -{ - CompEditorPrivate *priv; - - g_return_if_fail (editor != NULL); - g_return_if_fail (IS_COMP_EDITOR (editor)); - - priv = editor->priv; - - bonobo_ui_component_set_prop (priv->uic, path, attr, val, NULL); -} - - /* Brings attention to a window by raising it and giving it focus */ static void raise_and_focus (GtkWidget *widget) @@ -1367,129 +1290,6 @@ comp_editor_notify_client_changed (CompEditor *editor, ECal *client) comp_editor_page_notify_client_changed (COMP_EDITOR_PAGE (l->data), client); } -/* Menu Commands */ -static void -save_close_cmd (GtkWidget *widget, gpointer data) -{ - CompEditor *editor = COMP_EDITOR (data); - CompEditorPrivate *priv; - - priv = editor->priv; - - commit_all_fields (editor); - - 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)) - close_dialog (editor); -} - -static void -save_as_cmd (GtkWidget *widget, gpointer data) -{ - CompEditor *editor = COMP_EDITOR (data); - CompEditorPrivate *priv; - char *filename; - char *ical_string; - FILE *file; - - priv = editor->priv; - - commit_all_fields (editor); - - filename = e_file_dialog_save (_("Save as...")); - if (filename == NULL) - return; - - ical_string = e_cal_get_component_as_string (priv->client, - e_cal_component_get_icalcomponent (priv->comp)); - if (ical_string == NULL) { - g_warning ("Couldn't convert item to a string"); - return; - } - - file = fopen (filename, "w"); - if (file == NULL) { - g_warning ("Couldn't save item"); - return; - } - - fprintf (file, ical_string); - g_free (ical_string); - fclose (file); -} - -static void -delete_cmd (GtkWidget *widget, gpointer data) -{ - CompEditor *editor = COMP_EDITOR (data); - CompEditorPrivate *priv; - ECalComponentVType vtype; - - priv = editor->priv; - - vtype = e_cal_component_get_vtype (priv->comp); - - if (delete_component_dialog (priv->comp, FALSE, 1, vtype, GTK_WIDGET (editor))) { - if (itip_organizer_is_user (priv->comp, priv->client) - && cancel_component_dialog ((GtkWindow *) editor, - priv->client, priv->comp, TRUE)) - itip_send_comp (E_CAL_COMPONENT_METHOD_CANCEL, priv->comp, priv->client, NULL); - - delete_comp (editor); - } -} - -static void -print_cmd (GtkWidget *widget, gpointer data) -{ - CompEditor *editor = COMP_EDITOR (data); - ECalComponent *comp; - - commit_all_fields (editor); - - comp = comp_editor_get_current_comp (editor); - print_comp (comp, editor->priv->client, FALSE); - g_object_unref (comp); -} - -static void -print_preview_cmd (GtkWidget *widget, gpointer data) -{ - CompEditor *editor = COMP_EDITOR (data); - ECalComponent *comp; - - commit_all_fields (editor); - - comp = comp_editor_get_current_comp (editor); - print_comp (comp, editor->priv->client, TRUE); - g_object_unref (comp); -} - -static void -print_setup_cmd (GtkWidget *widget, gpointer data) -{ - CompEditor *editor = COMP_EDITOR (data); - CompEditorPrivate *priv; - - priv = editor->priv; - - print_setup (); -} - -static void -close_cmd (GtkWidget *widget, gpointer data) -{ - CompEditor *editor = COMP_EDITOR (data); - - commit_all_fields (editor); - - if (prompt_to_save_changes (editor, TRUE)) - close_dialog (editor); -} - static void page_changed_cb (GtkObject *obj, gpointer data) { @@ -1607,14 +1407,3 @@ obj_removed_cb (ECal *client, GList *uids, gpointer data) if (changed_component_dialog ((GtkWindow *) editor, priv->comp, TRUE, priv->changed)) close_dialog (editor); } - -static gint -delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data) -{ - CompEditor *editor = COMP_EDITOR (data); - - if (prompt_to_save_changes (editor, TRUE)) - close_dialog (editor); - - return TRUE; -} diff --git a/calendar/gui/dialogs/comp-editor.h b/calendar/gui/dialogs/comp-editor.h index b0b9521868..14846ec615 100644 --- a/calendar/gui/dialogs/comp-editor.h +++ b/calendar/gui/dialogs/comp-editor.h @@ -22,9 +22,6 @@ #define COMP_EDITOR_H #include -#include -#include -#include #include #include "../itip-utils.h" #include "comp-editor-page.h" @@ -43,14 +40,14 @@ G_BEGIN_DECLS typedef struct _CompEditorPrivate CompEditorPrivate; typedef struct { - BonoboWindow object; + GtkDialog object; /* Private data */ CompEditorPrivate *priv; } CompEditor; typedef struct { - BonoboWindowClass parent_class; + GtkDialogClass parent_class; /* Virtual functions */ void (* set_e_cal) (CompEditor *page, ECal *client); @@ -91,14 +88,6 @@ void comp_editor_delete_comp (CompEditor *editor); gboolean comp_editor_send_comp (CompEditor *editor, ECalComponentItipMethod method); gboolean comp_editor_close (CompEditor *editor); -void comp_editor_merge_ui (CompEditor *editor, - const char *filename, - BonoboUIVerb *verbs, - EPixmap *pixmaps); -void comp_editor_set_ui_prop (CompEditor *editor, - const char *path, - const char *attr, - const char *val); void comp_editor_focus (CompEditor *editor); void comp_editor_notify_client_changed (CompEditor *editor, ECal *client); diff --git a/calendar/gui/dialogs/event-editor.c b/calendar/gui/dialogs/event-editor.c index a035f6b87e..52065ea0b2 100644 --- a/calendar/gui/dialogs/event-editor.c +++ b/calendar/gui/dialogs/event-editor.c @@ -32,7 +32,6 @@ #include #include "event-page.h" -#include "alarm-page.h" #include "recurrence-page.h" #include "meeting-page.h" #include "schedule-page.h" @@ -41,7 +40,6 @@ struct _EventEditorPrivate { EventPage *event_page; - AlarmPage *alarm_page; RecurrencePage *recur_page; MeetingPage *meet_page; SchedulePage *sched_page; @@ -69,19 +67,6 @@ static void forward_cmd (GtkWidget *widget, gpointer data); static void model_row_change_insert_cb (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data); static void model_row_delete_cb (GtkTreeModel *model, GtkTreePath *path, gpointer data); -static EPixmap pixmaps [] = { - E_PIXMAP ("/Toolbar/Actions/ActionScheduleMeeting", "stock_people", E_ICON_SIZE_LARGE_TOOLBAR), - E_PIXMAP_END -}; - -static BonoboUIVerb verbs [] = { - BONOBO_UI_UNSAFE_VERB ("ActionScheduleMeeting", schedule_meeting_cmd), - BONOBO_UI_UNSAFE_VERB ("ActionRefreshMeeting", refresh_meeting_cmd), - BONOBO_UI_UNSAFE_VERB ("ActionCancelMeeting", cancel_meeting_cmd), - BONOBO_UI_UNSAFE_VERB ("ActionForward", forward_cmd), - - BONOBO_UI_VERB_END -}; static CompEditorClass *parent_class; @@ -118,45 +103,6 @@ event_editor_class_init (EventEditorClass *klass) gobject_class->finalize = event_editor_finalize; } -static void -set_menu_sens (EventEditor *ee) -{ - EventEditorPrivate *priv; - gboolean sens, existing, user, read_only = TRUE; - - priv = ee->priv; - - existing = comp_editor_get_existing_org (COMP_EDITOR (ee)); - user = comp_editor_get_user_org (COMP_EDITOR (ee)); - - e_cal_is_read_only (comp_editor_get_e_cal (COMP_EDITOR (ee)), &read_only, NULL); - - sens = priv->meeting_shown; - comp_editor_set_ui_prop (COMP_EDITOR (ee), - "/commands/ActionScheduleMeeting", - "sensitive", sens || read_only ? "0" : "1"); - - sens = priv->meeting_shown && existing && !user && !read_only; - comp_editor_set_ui_prop (COMP_EDITOR (ee), - "/commands/ActionRefreshMeeting", - "sensitive", sens ? "1" : "0"); - - sens = priv->meeting_shown && existing && user && !read_only; - comp_editor_set_ui_prop (COMP_EDITOR (ee), - "/commands/ActionCancelMeeting", - "sensitive", sens ? "1" : "0"); - - comp_editor_set_ui_prop (COMP_EDITOR (ee), - "/commands/FileSave", - "sensitive", read_only ? "0" : "1"); - comp_editor_set_ui_prop (COMP_EDITOR (ee), - "/commands/FileSaveAndClose", - "sensitive", read_only ? "0" : "1"); - comp_editor_set_ui_prop (COMP_EDITOR (ee), - "/commands/FileDelete", - "sensitive", read_only ? "0" : "1"); -} - static void init_widgets (EventEditor *ee) { @@ -175,7 +121,7 @@ init_widgets (EventEditor *ee) static void client_changed_cb (CompEditorPage *page, ECal *client, gpointer user_data) { - set_menu_sens (EVENT_EDITOR (user_data)); + //set_menu_sens (EVENT_EDITOR (user_data)); } /* Object initialization function for the event editor */ @@ -208,13 +154,6 @@ event_editor_construct (EventEditor *ee, ECal *client) g_signal_connect (G_OBJECT (priv->event_page), "client_changed", G_CALLBACK (client_changed_cb), ee); - priv->alarm_page = alarm_page_new (); - g_object_ref (priv->alarm_page); - gtk_object_sink (GTK_OBJECT (priv->alarm_page)); - comp_editor_append_page (COMP_EDITOR (ee), - COMP_EDITOR_PAGE (priv->alarm_page), - _("Reminder")); - priv->recur_page = recurrence_page_new (); g_object_ref (priv->recur_page); gtk_object_sink (GTK_OBJECT (priv->recur_page)); @@ -238,10 +177,7 @@ event_editor_construct (EventEditor *ee, ECal *client) comp_editor_set_e_cal (COMP_EDITOR (ee), client); - comp_editor_merge_ui (COMP_EDITOR (ee), "evolution-event-editor.xml", verbs, pixmaps); - init_widgets (ee); - set_menu_sens (ee); gtk_window_set_default_size (GTK_WINDOW (ee), 300, 225); return ee; @@ -349,7 +285,6 @@ event_editor_edit_comp (CompEditor *editor, ECalComponent *comp) } e_cal_component_free_attendee_list (attendees); - set_menu_sens (ee); comp_editor_set_needs_send (COMP_EDITOR (ee), priv->meeting_shown && itip_organizer_is_user (comp, client)); priv->updating = FALSE; @@ -403,7 +338,6 @@ event_editor_finalize (GObject *object) priv = ee->priv; g_object_unref (priv->event_page); - g_object_unref (priv->alarm_page); g_object_unref (priv->recur_page); g_object_unref (priv->meet_page); g_object_unref (priv->sched_page); @@ -450,7 +384,6 @@ show_meeting (EventEditor *ee) _("Meeting")); priv->meeting_shown = TRUE; - set_menu_sens (ee); comp_editor_set_changed (COMP_EDITOR (ee), priv->meeting_shown); comp_editor_set_needs_send (COMP_EDITOR (ee), priv->meeting_shown); } diff --git a/calendar/gui/dialogs/event-page.c b/calendar/gui/dialogs/event-page.c index d832cf4873..9c9d88f25b 100644 --- a/calendar/gui/dialogs/event-page.c +++ b/calendar/gui/dialogs/event-page.c @@ -43,6 +43,8 @@ #include "../e-timezone-entry.h" #include "comp-editor.h" #include "comp-editor-util.h" +#include "../e-alarm-list.h" +#include "alarm-list-dialog.h" #include "event-page.h" @@ -57,7 +59,9 @@ struct _EventPagePrivate { GtkWidget *main; GtkWidget *summary; + GtkWidget *summary_label; GtkWidget *location; + GtkWidget *location_label; GtkWidget *start_time; GtkWidget *end_time; @@ -67,19 +71,22 @@ struct _EventPagePrivate { GtkWidget *description; - GtkWidget *classification_public; - GtkWidget *classification_private; - GtkWidget *classification_confidential; + GtkWidget *classification; - GtkWidget *show_time_frame; - GtkWidget *show_time_as_free; GtkWidget *show_time_as_busy; + GtkWidget *alarm; + GtkWidget *alarm_time; + GtkWidget *alarm_warning; + GtkWidget *alarm_custom; + GtkWidget *categories_btn; GtkWidget *categories; GtkWidget *source_selector; + EAlarmList *alarm_list_store; + gboolean updating; /* This is TRUE if both the start & end timezone are the same. If the @@ -154,19 +161,20 @@ event_page_init (EventPage *epage) priv->main = NULL; priv->summary = NULL; + priv->summary_label = NULL; priv->location = NULL; + priv->location_label = NULL; priv->start_time = NULL; priv->end_time = NULL; priv->start_timezone = NULL; priv->end_timezone = NULL; priv->all_day_event = NULL; priv->description = NULL; - priv->classification_public = NULL; - priv->classification_private = NULL; - priv->classification_confidential = NULL; - priv->show_time_frame = NULL; - priv->show_time_as_free = NULL; + priv->classification = NULL; priv->show_time_as_busy = NULL; + priv->alarm = NULL; + priv->alarm_time = NULL; + priv->alarm_custom = NULL; priv->categories_btn = NULL; priv->categories = NULL; @@ -195,6 +203,11 @@ event_page_finalize (GObject *object) priv->xml = NULL; } + if (priv->alarm_list_store) { + g_object_unref (priv->alarm_list_store); + priv->alarm_list_store = NULL; + } + g_free (priv); epage->priv = NULL; @@ -211,9 +224,18 @@ static const int classification_map[] = { -1 }; -static const int transparency_map[] = { - E_CAL_COMPONENT_TRANSP_TRANSPARENT, - E_CAL_COMPONENT_TRANSP_OPAQUE, +enum { + ALARM_15_MINUTES, + ALARM_1_HOUR, + ALARM_1_DAY, + ALARM_USER_TIME +}; + +static const int alarm_map[] = { + ALARM_15_MINUTES, + ALARM_1_HOUR, + ALARM_1_DAY, + ALARM_USER_TIME, -1 }; @@ -398,43 +420,165 @@ clear_widgets (EventPage *epage) set_all_day (epage, FALSE); /* Classification */ - e_dialog_radio_set (priv->classification_public, - E_CAL_COMPONENT_CLASS_PRIVATE, classification_map); + e_dialog_option_menu_set (priv->classification, E_CAL_COMPONENT_CLASS_PRIVATE, classification_map); /* Show Time As (Transparency) */ - e_dialog_radio_set (priv->show_time_as_free, - E_CAL_COMPONENT_TRANSP_OPAQUE, transparency_map); + e_dialog_toggle_set (priv->show_time_as_busy, TRUE); + /* Alarm */ + e_dialog_toggle_set (priv->alarm, FALSE); + /* Categories */ e_dialog_editable_set (priv->categories, NULL); } +static gboolean +is_custom_alarm (ECalComponentAlarm *ca, int *alarm_type) +{ + ECalComponentAlarmTrigger trigger; + ECalComponentAlarmRepeat repeat; + ECalComponentAlarmAction action; + icalattach *attach; + + e_cal_component_alarm_get_action (ca, &action); + if (action != E_CAL_COMPONENT_ALARM_DISPLAY) + return TRUE; + + e_cal_component_alarm_get_attach (ca, &attach); + if (attach) + return TRUE; + +#if 0 + e_cal_component_alarm_get_description (ca, &desc); + if (attach) + return TRUE; +#endif + + e_cal_component_alarm_get_repeat (ca, &repeat); + if (repeat.repetitions != 0) + return TRUE; + + if (e_cal_component_alarm_has_attendees (ca)) + return TRUE; + + e_cal_component_alarm_get_trigger (ca, &trigger); + if (trigger.type != E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START) + return TRUE; + + if (trigger.u.rel_duration.is_neg != 1) + return TRUE; + + if (trigger.u.rel_duration.weeks != 0) + return TRUE; + + if (trigger.u.rel_duration.seconds != 0) + return TRUE; + + if (trigger.u.rel_duration.days == 1 + && trigger.u.rel_duration.hours == 0 + && trigger.u.rel_duration.minutes == 0) { + if (alarm_type) + *alarm_type = ALARM_1_DAY; + return FALSE; + } + + if (trigger.u.rel_duration.days == 0 + && trigger.u.rel_duration.hours == 1 + && trigger.u.rel_duration.minutes == 0) { + if (alarm_type) + *alarm_type = ALARM_1_HOUR; + return FALSE; + } + + if (trigger.u.rel_duration.days == 0 + && trigger.u.rel_duration.hours == 0 + && trigger.u.rel_duration.minutes == 15) { + if (alarm_type) + *alarm_type = ALARM_15_MINUTES; + return FALSE; + } + + /* FIXME User defined time */ + + return TRUE; +} + +static gboolean +is_custom_alarm_uid_list (ECalComponent *comp, GList *alarms, int *alarm_type) +{ + ECalComponentAlarm *ca; + gboolean result; + + if (g_list_length (alarms) > 1) + return TRUE; + + ca = e_cal_component_get_alarm (comp, alarms->data); + result = is_custom_alarm (ca, alarm_type); + e_cal_component_alarm_free (ca); + + return result; +} + +static gboolean +is_custom_alarm_store (EAlarmList *alarm_list_store, int *alarm_type) +{ + const ECalComponentAlarm *alarm; + GtkTreeModel *model; + GtkTreeIter iter; + gboolean valid_iter; + + model = GTK_TREE_MODEL (alarm_list_store); + + valid_iter = gtk_tree_model_get_iter_first (model, &iter); + if (!valid_iter) + return FALSE; + + alarm = e_alarm_list_get_alarm (alarm_list_store, &iter); + if (is_custom_alarm (( ECalComponentAlarm *)alarm, alarm_type)) + return TRUE; + + valid_iter = gtk_tree_model_iter_next (model, &iter); + if (valid_iter) + return TRUE; + + return FALSE; +} + static void sensitize_widgets (EventPage *epage) { - gboolean read_only; + gboolean read_only, custom, alarm; EventPagePrivate *priv; - + priv = epage->priv; if (!e_cal_is_read_only (COMP_EDITOR_PAGE (epage)->client, &read_only, NULL)) read_only = TRUE; - gtk_widget_set_sensitive (priv->summary, !read_only); - gtk_widget_set_sensitive (priv->location, !read_only); + custom = is_custom_alarm_store (priv->alarm_list_store, NULL); + alarm = e_dialog_toggle_get (priv->alarm); + + gtk_widget_set_sensitive (priv->summary_label, !read_only); + gtk_entry_set_editable (GTK_ENTRY (priv->summary), !read_only); + gtk_widget_set_sensitive (priv->location_label, !read_only); + gtk_entry_set_editable (GTK_ENTRY (priv->location), !read_only); gtk_widget_set_sensitive (priv->start_time, !read_only); gtk_widget_set_sensitive (priv->start_timezone, !read_only); gtk_widget_set_sensitive (priv->end_time, !read_only); gtk_widget_set_sensitive (priv->end_timezone, !read_only); gtk_widget_set_sensitive (priv->all_day_event, !read_only); gtk_widget_set_sensitive (priv->description, !read_only); - gtk_widget_set_sensitive (priv->classification_public, !read_only); - gtk_widget_set_sensitive (priv->classification_private, !read_only); - gtk_widget_set_sensitive (priv->classification_confidential, !read_only); - gtk_widget_set_sensitive (priv->show_time_as_free, !read_only); + gtk_widget_set_sensitive (priv->classification, !read_only); gtk_widget_set_sensitive (priv->show_time_as_busy, !read_only); + gtk_widget_set_sensitive (priv->alarm, !read_only); + gtk_widget_set_sensitive (priv->alarm_time, !read_only && !custom && alarm); + gtk_widget_set_sensitive (priv->alarm_custom, !read_only && alarm); + if (custom) + gtk_widget_show (priv->alarm_warning); + else + gtk_widget_hide (priv->alarm_warning); gtk_widget_set_sensitive (priv->categories_btn, !read_only); - gtk_widget_set_sensitive (priv->categories, !read_only); + gtk_entry_set_editable (GTK_ENTRY (priv->categories), !read_only); } /* fill_widgets handler for the event page */ @@ -499,57 +643,61 @@ event_page_fill_widgets (CompEditorPage *page, ECalComponent *comp) e_cal_component_free_datetime (&end_date); /* Classification */ - e_cal_component_get_classification (comp, &cl); switch (cl) { case E_CAL_COMPONENT_CLASS_PUBLIC: - e_dialog_radio_set (priv->classification_public, - E_CAL_COMPONENT_CLASS_PUBLIC, - classification_map); - break; - case E_CAL_COMPONENT_CLASS_PRIVATE: - e_dialog_radio_set (priv->classification_public, - E_CAL_COMPONENT_CLASS_PRIVATE, - classification_map); - break; - case E_CAL_COMPONENT_CLASS_CONFIDENTIAL: - e_dialog_radio_set (priv->classification_public, - E_CAL_COMPONENT_CLASS_CONFIDENTIAL, - classification_map); break; - default: - /* default to PUBLIC */ - e_dialog_radio_set (priv->classification_public, - E_CAL_COMPONENT_CLASS_PUBLIC, - classification_map); + cl = E_CAL_COMPONENT_CLASS_PUBLIC; break; } - + e_dialog_option_menu_set (priv->classification, cl, classification_map); /* Show Time As (Transparency) */ e_cal_component_get_transparency (comp, &transparency); switch (transparency) { case E_CAL_COMPONENT_TRANSP_TRANSPARENT: - e_dialog_radio_set (priv->show_time_as_free, - E_CAL_COMPONENT_TRANSP_TRANSPARENT, - transparency_map); + e_dialog_toggle_set (priv->show_time_as_busy, FALSE); break; default: - e_dialog_radio_set (priv->show_time_as_free, - E_CAL_COMPONENT_TRANSP_OPAQUE, - transparency_map); + e_dialog_toggle_set (priv->show_time_as_busy, TRUE); break; } if (e_cal_get_static_capability (page->client, CAL_STATIC_CAPABILITY_NO_TRANSPARENCY)) - gtk_widget_hide (priv->show_time_frame); + gtk_widget_hide (priv->show_time_as_busy); else - gtk_widget_show (priv->show_time_frame); + gtk_widget_show (priv->show_time_as_busy); + /* Alarms */ + g_signal_handlers_block_matched (priv->alarm, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, epage); + if (e_cal_component_has_alarms (comp)) { + GList *alarms, *l; + int alarm_type; + + e_dialog_toggle_set (priv->alarm, TRUE); + + alarms = e_cal_component_get_alarm_uids (comp); + if (!is_custom_alarm_uid_list (comp, alarms, &alarm_type)) + e_dialog_option_menu_set (priv->alarm_time, alarm_type, alarm_map); + + for (l = alarms; l != NULL; l = l->next) { + ECalComponentAlarm *ca; + + ca = e_cal_component_get_alarm (comp, l->data); + e_alarm_list_append (priv->alarm_list_store, NULL, ca); + e_cal_component_alarm_free (ca); + } + + cal_obj_uid_list_free (alarms); + } else { + e_dialog_toggle_set (priv->alarm, FALSE); + } + g_signal_handlers_unblock_matched (priv->alarm, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, epage); + /* Categories */ e_cal_component_get_categories (comp, &categories); e_dialog_editable_set (priv->categories, categories); @@ -573,10 +721,9 @@ event_page_fill_component (CompEditorPage *page, ECalComponent *comp) EventPagePrivate *priv; ECalComponentDateTime start_date, end_date; struct icaltimetype start_tt, end_tt; - gboolean all_day_event, start_date_set, end_date_set; + gboolean all_day_event, start_date_set, end_date_set, busy; char *cat, *str; ECalComponentClassification classif; - ECalComponentTransparency transparency; GtkTextBuffer *text_buffer; GtkTextIter text_iter_start, text_iter_end; @@ -715,17 +862,54 @@ event_page_fill_component (CompEditorPage *page, ECalComponent *comp) g_free (str); /* Classification */ - - classif = e_dialog_radio_get (priv->classification_public, - classification_map); + classif = e_dialog_option_menu_get (priv->classification, classification_map); e_cal_component_set_classification (comp, classif); /* Show Time As (Transparency) */ + busy = e_dialog_toggle_get (priv->show_time_as_busy); + e_cal_component_set_transparency (comp, busy ? E_CAL_COMPONENT_TRANSP_TRANSPARENT : E_CAL_COMPONENT_TRANSP_OPAQUE); + + /* Alarm */ + e_cal_component_remove_all_alarms (comp); + if (e_dialog_toggle_get (priv->alarm)) { + ECalComponentAlarm *ca; + ECalComponentText summary; + ECalComponentAlarmTrigger trigger; + int alarm_type; + + ca = e_cal_component_alarm_new (); + + e_cal_component_get_summary (comp, &summary); + e_cal_component_alarm_set_description (ca, &summary); + + e_cal_component_alarm_set_action (ca, E_CAL_COMPONENT_ALARM_DISPLAY); - transparency = e_dialog_radio_get (priv->show_time_as_free, - transparency_map); - e_cal_component_set_transparency (comp, transparency); - + memset (&trigger, 0, sizeof (ECalComponentAlarmTrigger)); + trigger.type = E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START; + trigger.u.rel_duration.is_neg = 1; + + alarm_type = e_dialog_option_menu_get (priv->alarm_time, alarm_map); + switch (alarm_type) { + case ALARM_15_MINUTES: + trigger.u.rel_duration.minutes = 15; + break; + + case ALARM_1_HOUR: + trigger.u.rel_duration.hours = 1; + break; + + case ALARM_1_DAY: + trigger.u.rel_duration.days = 1; + break; + + default: + break; + } + e_cal_component_alarm_set_trigger (ca, trigger); + + e_cal_component_add_alarm (comp, ca); + } + return TRUE; } @@ -801,8 +985,10 @@ get_widgets (EventPage *epage) gtk_widget_ref (priv->main); gtk_container_remove (GTK_CONTAINER (priv->main->parent), priv->main); - priv->summary = GW ("general-summary"); + priv->summary = GW ("summary"); + priv->summary_label = GW ("summary-label"); priv->location = GW ("location"); + priv->location_label = GW ("location-label"); /* Glade's visibility flag doesn't seem to work for custom widgets */ priv->start_time = GW ("start-time"); @@ -816,14 +1002,15 @@ get_widgets (EventPage *epage) priv->description = GW ("description"); - priv->classification_public = GW ("classification-public"); - priv->classification_private = GW ("classification-private"); - priv->classification_confidential = GW ("classification-confidential"); + priv->classification = GW ("classification"); - priv->show_time_frame = GW ("show-time-frame"); - priv->show_time_as_free = GW ("show-time-as-free"); priv->show_time_as_busy = GW ("show-time-as-busy"); + priv->alarm = GW ("alarm"); + priv->alarm_time = GW ("alarm-time"); + priv->alarm_warning = GW ("alarm-warning"); + priv->alarm_custom = GW ("alarm-custom"); + priv->categories_btn = GW ("categories-button"); priv->categories = GW ("categories"); @@ -839,12 +1026,12 @@ get_widgets (EventPage *epage) && priv->end_timezone && priv->all_day_event && priv->description - && priv->classification_public - && priv->classification_private - && priv->classification_confidential - && priv->show_time_frame - && priv->show_time_as_free + && priv->classification && priv->show_time_as_busy + && priv->alarm + && priv->alarm_time + && priv->alarm_warning + && priv->alarm_custom && priv->categories_btn && priv->categories); } @@ -1306,6 +1493,69 @@ source_changed_cb (GtkWidget *widget, ESource *source, gpointer data) } } +static void +alarm_changed_cb (GtkWidget *widget, gpointer data) +{ + EventPage *epage; + EventPagePrivate *priv; + + epage = EVENT_PAGE (data); + priv = epage->priv; + + if (e_dialog_toggle_get (priv->alarm)) { + ECalComponentAlarm *ca; + ECalComponentAlarmTrigger trigger; + int alarm_type; + + ca = e_cal_component_alarm_new (); + + e_cal_component_alarm_set_action (ca, E_CAL_COMPONENT_ALARM_DISPLAY); + + memset (&trigger, 0, sizeof (ECalComponentAlarmTrigger)); + trigger.type = E_CAL_COMPONENT_ALARM_TRIGGER_RELATIVE_START; + trigger.u.rel_duration.is_neg = 1; + + alarm_type = e_dialog_option_menu_get (priv->alarm_time, alarm_map); + switch (alarm_type) { + case ALARM_15_MINUTES: + trigger.u.rel_duration.minutes = 15; + break; + + case ALARM_1_HOUR: + trigger.u.rel_duration.hours = 1; + break; + + case ALARM_1_DAY: + trigger.u.rel_duration.days = 1; + break; + + default: + break; + } + e_cal_component_alarm_set_trigger (ca, trigger); + + e_alarm_list_append (priv->alarm_list_store, NULL, ca); + } else { + e_alarm_list_clear (priv->alarm_list_store); + } + + sensitize_widgets (epage); +} + +static void +alarm_custom_clicked_cb (GtkWidget *widget, gpointer data) +{ + EventPage *epage; + EventPagePrivate *priv; + + epage = EVENT_PAGE (data); + priv = epage->priv; + + alarm_list_dialog_run (gtk_widget_get_toplevel (priv->main), COMP_EDITOR_PAGE (epage)->client, priv->alarm_list_store); + + sensitize_widgets (epage); +} + /* Hooks the widget signals */ static gboolean init_widgets (EventPage *epage) @@ -1354,6 +1604,19 @@ init_widgets (EventPage *epage) g_signal_connect((priv->categories_btn), "clicked", G_CALLBACK (categories_clicked_cb), epage); + /* Source selector */ + g_signal_connect((priv->source_selector), "source_selected", + G_CALLBACK (source_changed_cb), epage); + + /* Alarms */ + priv->alarm_list_store = e_alarm_list_new (); + + g_signal_connect((priv->alarm), + "toggled", G_CALLBACK (alarm_changed_cb), + epage); + g_signal_connect(priv->alarm_custom, "clicked", + G_CALLBACK (alarm_custom_clicked_cb), epage); + /* Connect the default signal handler to use to make sure we notify * upstream of changes to the widget values. */ @@ -1376,25 +1639,20 @@ init_widgets (EventPage *epage) G_CALLBACK (field_changed_cb), epage); g_signal_connect((priv->all_day_event), "toggled", G_CALLBACK (field_changed_cb), epage); - g_signal_connect((priv->classification_public), - "toggled", G_CALLBACK (field_changed_cb), - epage); - g_signal_connect((priv->classification_private), - "toggled", G_CALLBACK (field_changed_cb), + g_signal_connect((priv->classification), + "changed", G_CALLBACK (field_changed_cb), epage); - g_signal_connect((priv->classification_confidential), + g_signal_connect((priv->show_time_as_busy), "toggled", G_CALLBACK (field_changed_cb), epage); - g_signal_connect((priv->show_time_as_free), + g_signal_connect((priv->alarm), "toggled", G_CALLBACK (field_changed_cb), epage); - g_signal_connect((priv->show_time_as_busy), - "toggled", G_CALLBACK (field_changed_cb), + g_signal_connect((priv->alarm_time), + "changed", G_CALLBACK (field_changed_cb), epage); g_signal_connect((priv->categories), "changed", G_CALLBACK (field_changed_cb), epage); - g_signal_connect((priv->source_selector), "source_selected", - G_CALLBACK (source_changed_cb), epage); /* Set the default timezone, so the timezone entry may be hidden. */ zone = calendar_config_get_icaltimezone (); diff --git a/calendar/gui/dialogs/event-page.glade b/calendar/gui/dialogs/event-page.glade index 46e1cc0bb0..6c46950255 100644 --- a/calendar/gui/dialogs/event-page.glade +++ b/calendar/gui/dialogs/event-page.glade @@ -10,6 +10,11 @@ False True False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST @@ -19,144 +24,75 @@ 6 - + True - 2 - 2 - False - 6 - 6 - - - - True - Su_mmary: - True - False - GTK_JUSTIFY_CENTER - False - False - 7.45058e-09 - 0.5 - 0 - 0 - general-summary - - - 0 - 1 - 0 - 1 - fill - - - + <b>Basics</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + - - - True - True - True - True - 0 - - True - * - False - - - 1 - 2 - 0 - 1 - - - + + + True + False + 0 - + True - L_ocation: - True + + False False - GTK_JUSTIFY_CENTER + GTK_JUSTIFY_LEFT False False - 7.45058e-09 + 0.5 0.5 - 0 + 12 0 - location - 0 - 1 - 1 - 2 - fill - - - - - - - True - True - True - True - 0 - - True - * - False - - - 1 - 2 - 1 - 2 - + 0 + False + False - - - 0 - False - True - - - - - - True - 0 - 0.5 - GTK_SHADOW_ETCHED_IN - - 6 + True - 2 - 4 + 5 + 2 False 6 6 - + True - _Start time: + Su_mmary: True False GTK_JUSTIFY_CENTER False False - 0 + 7.45058e-09 0.5 0 0 - start-time 0 @@ -169,19 +105,40 @@ - + True - _End time: + True + True + True + 0 + + True + * + False + + + 1 + 2 + 0 + 1 + + + + + + + True + Locatio_n: True False GTK_JUSTIFY_CENTER False False - 0 + 7.45058e-09 0.5 0 0 - end-time + location 0 @@ -194,200 +151,129 @@ - - True - True - make_date_edit - - - 0 - 0 - Tue, 16 May 2000 19:11:05 GMT - - - 1 - 2 - 0 - 1 - - - - - - + True True - make_date_edit - 0 - 0 - Tue, 16 May 2000 19:11:10 GMT + True + True + 0 + + True + * + False 1 2 1 2 - + - + True - make_timezone_entry - 0 - 0 - Mon, 18 Jun 2001 23:51:40 GMT - - - 2 - 3 - 1 - 2 - - fill - - + GTK_POLICY_NEVER + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT - - - True - make_timezone_entry - 0 - 0 - Mon, 18 Jun 2001 23:51:34 GMT + + + True + True + True + False + True + GTK_JUSTIFY_LEFT + GTK_WRAP_WORD + True + 0 + 0 + 0 + 0 + 0 + 0 + + + - 2 - 3 - 0 - 1 + 1 + 2 + 4 + 5 fill fill - + True - 1 - 7.45058e-09 - 0 - 0 - - - - True - True - A_ll day event - True - GTK_RELIEF_NORMAL - False - False - True - - + Classi_fication: + True + False + GTK_JUSTIFY_CENTER + False + False + 7.45058e-09 + 0.5 + 0 + 0 + location - 3 - 4 - 0 - 2 - fill + 0 + 1 + 2 + 3 + fill + - - - - - - True - Date & Time - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - label_item - - - - - 0 - False - False - - - - - - True - GTK_POLICY_NEVER - GTK_POLICY_AUTOMATIC - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT - - - - True - True - True - GTK_JUSTIFY_LEFT - GTK_WRAP_WORD - True - 0 - 0 - 0 - 0 - 0 - 0 - - - - - - 0 - True - True - - - - - - True - False - 6 - - - - True - 0 - 0.5 - GTK_SHADOW_ETCHED_IN - - 6 + True False 6 - + True True - Pu_blic - True - GTK_RELIEF_NORMAL - True - False - True + 0 + + + + + + + True + Public + True + + + + + + True + Private + True + + + + + + True + Confidential + True + + + + 0 @@ -397,35 +283,33 @@ - + True - True - Pri_vate + Cal_endar: True - GTK_RELIEF_NORMAL - False - False - True - classification-public + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 0 - True - True + False + False - + True - True - Co_nfidential - True - GTK_RELIEF_NORMAL - False - False - True - classification-public + event_page_create_source_option_menu + 0 + 0 + Wed, 17 Dec 2003 18:20:26 GMT 0 @@ -434,200 +318,506 @@ + + 1 + 2 + 2 + 3 + fill + fill + - + True - Classification - False + True + Ca_tegories... + True + GTK_RELIEF_NORMAL + True + + + 0 + 1 + 3 + 4 + fill + + + + + + + True + True + True + True + 0 + + True + * + False + + + 1 + 2 + 3 + 4 + + + + + + + True + _Description: + True False - GTK_JUSTIFY_LEFT + GTK_JUSTIFY_CENTER False False - 0.5 - 0.5 + 7.45058e-09 + 0 0 0 + description - label_item + 0 + 1 + 4 + 5 + fill + fill 0 - False + True True - - - - True - 0 - 0.5 - GTK_SHADOW_ETCHED_IN - + + + 0 + False + False + + + + + + True + <b>Date and Time</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + False + 0 + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 12 + 0 + + + 0 + False + False + + + + + + 6 + True + 4 + 4 + False + 6 + 6 + + + + True + True + make_date_edit + 0 + 0 + Tue, 16 May 2000 19:11:05 GMT + + + 1 + 2 + 0 + 1 + + + + + + + True + True + make_date_edit + 0 + 0 + Tue, 16 May 2000 19:11:10 GMT + + + 1 + 2 + 1 + 2 + + + + + + + True + make_timezone_entry + 0 + 0 + Mon, 18 Jun 2001 23:51:40 GMT + + + 2 + 3 + 1 + 2 + + fill + + + + + + True + _Start time: + True + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + start-time + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + _End time: + True + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + end-time + + + 0 + 1 + 1 + 2 + fill + + + + - - 6 + + True + True + A_ll day event + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 3 + 4 + 0 + 1 + fill + + + + + + + True + make_timezone_entry + 0 + 0 + Mon, 18 Jun 2001 23:51:34 GMT + + + 2 + 3 + 0 + 1 + + fill + + + + + + True + True + Show time as _busy + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 3 + 4 + 1 + 2 + fill + + + + + + + True + True + _Alarm + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + 1 + 2 + 3 + fill + + + + + + True False 6 - + True True - F_ree - True - GTK_RELIEF_NORMAL - False - False - True + 0 + + + + + + + True + 15 minutes before appointment + True + + + + + + True + 1 hour before appointment + True + + + + + + True + 1 day before appointment + True + + + + 0 - True - True + False + False - + True True - B_usy - True GTK_RELIEF_NORMAL - False - False - True - show-time-as-free + True + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-preferences + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + C_ustomize... + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + 0 - True - True + False + False + + 1 + 4 + 2 + 3 + fill + fill + - - True - Show Time As + + This appointment has customized alarms False False GTK_JUSTIFY_LEFT False False - 0.5 + 0 0.5 0 0 - label_item + 1 + 2 + 3 + 4 + - - 0 - False - True - - - - - 0 - False - False - - - - - - True - False - 6 - - - - True - True - Ca_tegories... - True - GTK_RELIEF_NORMAL - - - 0 - False - False - - - - - - True - True - True - True - 0 - - True - * - False - 0 True True - - - - True - Calendar: - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - event_page_create_source_option_menu - 0 - 0 - Wed, 17 Dec 2003 18:20:26 GMT - - - 0 - False - True - - 0 False - True + False diff --git a/calendar/gui/dialogs/meeting-page.c b/calendar/gui/dialogs/meeting-page.c index ac193a7ce7..617ee91652 100644 --- a/calendar/gui/dialogs/meeting-page.c +++ b/calendar/gui/dialogs/meeting-page.c @@ -69,12 +69,14 @@ struct _MeetingPagePrivate { /* Widgets from the Glade file */ GtkWidget *main; + GtkWidget *list_box; GtkWidget *organizer_table; GtkWidget *organizer; GtkWidget *existing_organizer_table; GtkWidget *existing_organizer; GtkWidget *existing_organizer_btn; GtkWidget *add; + GtkWidget *remove; GtkWidget *invite; /* ListView stuff */ @@ -328,6 +330,7 @@ sensitize_widgets (MeetingPage *mpage) 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); + gtk_widget_set_sensitive (priv->remove, !read_only); gtk_widget_set_sensitive (priv->invite, !read_only); gtk_widget_set_sensitive (priv->list_view, !read_only); } @@ -369,8 +372,9 @@ meeting_page_fill_widgets (CompEditorPage *page, ECalComponent *comp) gtk_widget_hide (priv->organizer_table); gtk_widget_show (priv->existing_organizer_table); if (itip_organizer_is_user (comp, page->client)) { - gtk_widget_show (priv->invite); - gtk_widget_show (priv->add); + gtk_widget_set_sensitive (priv->invite, TRUE); + gtk_widget_set_sensitive (priv->add, TRUE); + gtk_widget_set_sensitive (priv->remove, TRUE); if (e_cal_get_static_capability ( page->client, CAL_STATIC_CAPABILITY_ORGANIZER_NOT_EMAIL_ADDRESS)) @@ -380,8 +384,9 @@ meeting_page_fill_widgets (CompEditorPage *page, ECalComponent *comp) page->client, CAL_STATIC_CAPABILITY_ORGANIZER_NOT_EMAIL_ADDRESS)) gtk_widget_hide (priv->existing_organizer_btn); - gtk_widget_hide (priv->invite); - gtk_widget_hide (priv->add); + gtk_widget_set_sensitive (priv->invite, FALSE); + gtk_widget_set_sensitive (priv->add, FALSE); + gtk_widget_set_sensitive (priv->remove, FALSE); } if (organizer.cn != NULL) @@ -483,6 +488,8 @@ get_widgets (MeetingPage *mpage) if (!priv->main) return FALSE; + priv->list_box = GW ("list-box"); + /* Get the GtkAccelGroup from the toplevel window, so we can install it when the notebook page is mapped. */ toplevel = gtk_widget_get_toplevel (priv->main); @@ -508,12 +515,15 @@ get_widgets (MeetingPage *mpage) /* Buttons */ priv->add = GW ("add-attendee"); + priv->remove = GW ("remove-attendee"); priv->invite = GW ("invite"); #undef GW - return (priv->invite + return (priv->list_box + && priv->invite && priv->add + && priv->remove && priv->organizer_table && priv->organizer && priv->existing_organizer_table @@ -563,8 +573,9 @@ change_clicked_cb (GtkWidget *widget, gpointer data) gtk_widget_show (priv->organizer_table); gtk_widget_hide (priv->existing_organizer_table); - gtk_widget_show (priv->invite); - gtk_widget_show (priv->add); + gtk_widget_set_sensitive (priv->invite, TRUE); + gtk_widget_set_sensitive (priv->add, TRUE); + gtk_widget_set_sensitive (priv->remove, TRUE); comp_editor_page_notify_changed (COMP_EDITOR_PAGE (mpage)); @@ -580,6 +591,11 @@ add_clicked_cb (GtkButton *btn, MeetingPage *mpage) e_meeting_list_view_edit (mpage->priv->list_view, attendee); } +static void +remove_clicked_cb (GtkButton *btn, MeetingPage *mpage) +{ +} + /* Function called to invite more people */ static void invite_cb (GtkWidget *widget, gpointer data) @@ -611,7 +627,10 @@ init_widgets (MeetingPage *mpage) /* Add attendee button */ g_signal_connect (priv->add, "clicked", G_CALLBACK (add_clicked_cb), mpage); - /* Invite button */ + /* Remove attendee button */ + g_signal_connect (priv->remove, "clicked", G_CALLBACK (remove_clicked_cb), mpage); + + /* Contacts button */ g_signal_connect(priv->invite, "clicked", G_CALLBACK (invite_cb), mpage); } @@ -813,10 +832,11 @@ meeting_page_construct (MeetingPage *mpage, EMeetingStore *ems, gtk_widget_show (GTK_WIDGET (priv->list_view)); sw = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN); gtk_widget_show (sw); gtk_container_add (GTK_CONTAINER (sw), GTK_WIDGET (priv->list_view)); - gtk_box_pack_start (GTK_BOX (priv->main), sw, TRUE, TRUE, 6); + gtk_box_pack_start (GTK_BOX (priv->list_box), sw, TRUE, TRUE, 6); /* Init the widget signals */ init_widgets (mpage); diff --git a/calendar/gui/dialogs/meeting-page.glade b/calendar/gui/dialogs/meeting-page.glade index 5a13ad5c77..a2709cb180 100644 --- a/calendar/gui/dialogs/meeting-page.glade +++ b/calendar/gui/dialogs/meeting-page.glade @@ -2,7 +2,6 @@ - window1 @@ -11,6 +10,11 @@ False True False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST @@ -20,106 +24,299 @@ 6 - + + True + <b>Organizer</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + True False - 6 + 0 + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 12 + 0 + + + 0 + False + False + + - - 6 + True - 1 - 2 False - 6 - 6 + 6 - + True - True - False - False - True - False + 1 + 2 + False + 6 + 6 - - + + True - True - True - True - 0 - - True - * - False + _Organizer: + True + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + entry2 + + 0 + 1 + 0 + 1 + fill + + - - + + True - GTK_SELECTION_BROWSE + True + False + False + True + False - - + + True + True + True + True + 0 + + True + * + False + + + + + + True + GTK_SELECTION_BROWSE - + True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + + 1 + 2 + 0 + 1 + + - 1 - 2 - 0 - 1 - + 0 + False + False - + True - Organizer: - False - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 + 1 + 3 + False + 6 + 6 + + + + True + _Organizer: + True + False + GTK_JUSTIFY_CENTER + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + 1 + 0 + 1 + + + + + + + + True + True + Change Or_ganizer + True + GTK_RELIEF_NORMAL + True + + + 2 + 3 + 0 + 1 + + + + + + + + True + None + False + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 0 + 1 + fill + + + - 0 - 1 - 0 - 1 - fill - + 0 + False + False + + 0 + True + True + + + + + 0 + False + False + + + + + + True + <b>Attendees</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + False + 0 + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 12 + 0 + 0 False @@ -128,128 +325,123 @@ - - 6 + True - 1 - 3 - False - 6 - 6 + GTK_BUTTONBOX_START + 6 - + True - Organizer: - False - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 + True + True + gtk-add + True + GTK_RELIEF_NORMAL + True - - 0 - 1 - 0 - 1 - - - - + True + True True - _Change Organizer - True + gtk-remove + True GTK_RELIEF_NORMAL + True - - 2 - 3 - 0 - 1 - - - - + True - None - False - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 + True + True + GTK_RELIEF_NORMAL + True + + + + True + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 + + + + True + False + 2 + + + + True + gtk-jump-to + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + Con_tacts... + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + - - 1 - 2 - 0 - 1 - - 0 False - False + True + GTK_PACK_END - - - 0 - False - False - - - - - True - True - Add A_ttendee - True - GTK_RELIEF_NORMAL - - - 0 - False - False - - - - - - True - True - Add attendees from addressbook. - True - GTK_RELIEF_NORMAL + + + 0 - False - False - GTK_PACK_END + True + True - - - - diff --git a/calendar/gui/dialogs/recurrence-page.c b/calendar/gui/dialogs/recurrence-page.c index 50bdb108b9..e58fb28906 100644 --- a/calendar/gui/dialogs/recurrence-page.c +++ b/calendar/gui/dialogs/recurrence-page.c @@ -37,6 +37,8 @@ #include #include #include +#include +#include #include #include #include @@ -143,13 +145,9 @@ struct _RecurrencePagePrivate { /* Widgets from the Glade file */ GtkWidget *main; - GtkWidget *summary; - GtkWidget *date_time; - - GtkWidget *none; - GtkWidget *simple; - GtkWidget *custom; - + GtkWidget *recurs; + gboolean custom; + GtkWidget *params; GtkWidget *interval_value; GtkWidget *interval_unit; @@ -181,7 +179,6 @@ struct _RecurrencePagePrivate { int ending_count; /* More widgets from the Glade file */ - GtkWidget *exception_date; GtkWidget *exception_list; /* This is a GtkTreeView now */ GtkWidget *exception_add; GtkWidget *exception_modify; @@ -209,7 +206,6 @@ static GtkWidget *recurrence_page_get_widget (CompEditorPage *page); static void recurrence_page_focus_main_widget (CompEditorPage *page); static gboolean recurrence_page_fill_widgets (CompEditorPage *page, ECalComponent *comp); static gboolean recurrence_page_fill_component (CompEditorPage *page, ECalComponent *comp); -static void recurrence_page_set_summary (CompEditorPage *page, const char *summary); static void recurrence_page_set_dates (CompEditorPage *page, CompEditorPageDates *dates); static void field_changed (RecurrencePage *apage); @@ -246,7 +242,6 @@ recurrence_page_class_init (RecurrencePageClass *class) editor_page_class->focus_main_widget = recurrence_page_focus_main_widget; editor_page_class->fill_widgets = recurrence_page_fill_widgets; editor_page_class->fill_component = recurrence_page_fill_component; - editor_page_class->set_summary = recurrence_page_set_summary; editor_page_class->set_dates = recurrence_page_set_dates; object_class->finalize = recurrence_page_finalize; @@ -264,11 +259,8 @@ recurrence_page_init (RecurrencePage *rpage) priv->xml = NULL; priv->main = NULL; - priv->summary = NULL; - priv->date_time = NULL; - priv->none = NULL; - priv->simple = NULL; - priv->custom = NULL; + priv->recurs = NULL; + priv->custom = FALSE; priv->params = NULL; priv->interval_value = NULL; priv->interval_unit = NULL; @@ -281,7 +273,6 @@ recurrence_page_init (RecurrencePage *rpage) priv->month_num_menu = NULL; priv->ending_date_edit = NULL; priv->ending_count_spin = NULL; - priv->exception_date = NULL; priv->exception_list = NULL; priv->exception_add = NULL; priv->exception_modify = NULL; @@ -360,14 +351,7 @@ recurrence_page_focus_main_widget (CompEditorPage *page) rpage = RECURRENCE_PAGE (page); priv = rpage->priv; - if (e_dialog_toggle_get (priv->none)) - gtk_widget_grab_focus (priv->none); - else if (e_dialog_toggle_get (priv->simple)) - gtk_widget_grab_focus (priv->simple); - else if (e_dialog_toggle_get (priv->custom)) - gtk_widget_grab_focus (priv->custom); - else - g_assert_not_reached (); + gtk_widget_grab_focus (priv->recurs); } /* Fills the widgets with default values */ @@ -380,19 +364,17 @@ clear_widgets (RecurrencePage *rpage) priv = rpage->priv; + priv->custom = FALSE; + priv->weekday_day_mask = 0; priv->month_index = 1; priv->month_num = MONTH_NUM_DAY; priv->month_day = MONTH_DAY_NTH; - g_signal_handlers_block_matched (priv->none, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, rpage); - g_signal_handlers_block_matched (priv->simple, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, rpage); - g_signal_handlers_block_matched (priv->custom, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, rpage); - e_dialog_radio_set (priv->none, RECUR_NONE, type_map); - g_signal_handlers_unblock_matched (priv->none, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, rpage); - g_signal_handlers_unblock_matched (priv->simple, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, rpage); - g_signal_handlers_unblock_matched (priv->custom, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, rpage); + g_signal_handlers_block_matched (priv->recurs, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, rpage); + e_dialog_toggle_set (priv->recurs, FALSE); + g_signal_handlers_unblock_matched (priv->recurs, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, rpage); adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (priv->interval_value)); g_signal_handlers_block_matched (adj, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, rpage); @@ -506,13 +488,13 @@ static void sensitize_recur_widgets (RecurrencePage *rpage) { RecurrencePagePrivate *priv; - enum recur_type type; + gboolean recurs; GtkWidget *label; priv = rpage->priv; - type = e_dialog_radio_get (priv->none, type_map); - + recurs = e_dialog_toggle_get (priv->recurs); + /* We can't preview that well for instances right now */ if (e_cal_component_is_instance (priv->comp)) gtk_widget_set_sensitive (priv->preview_calendar, FALSE); @@ -522,20 +504,7 @@ sensitize_recur_widgets (RecurrencePage *rpage) if (GTK_BIN (priv->custom_warning_bin)->child) gtk_widget_destroy (GTK_BIN (priv->custom_warning_bin)->child); - switch (type) { - case RECUR_NONE: - gtk_widget_set_sensitive (priv->params, FALSE); - gtk_widget_show (priv->params); - gtk_widget_hide (priv->custom_warning_bin); - break; - - case RECUR_SIMPLE: - gtk_widget_set_sensitive (priv->params, TRUE); - gtk_widget_show (priv->params); - gtk_widget_hide (priv->custom_warning_bin); - break; - - case RECUR_CUSTOM: + if (recurs && priv->custom) { gtk_widget_set_sensitive (priv->params, FALSE); gtk_widget_hide (priv->params); @@ -545,10 +514,14 @@ sensitize_recur_widgets (RecurrencePage *rpage) gtk_container_add (GTK_CONTAINER (priv->custom_warning_bin), label); gtk_widget_show_all (priv->custom_warning_bin); - break; - - default: - g_assert_not_reached (); + } else if (recurs) { + gtk_widget_set_sensitive (priv->params, TRUE); + gtk_widget_show (priv->params); + gtk_widget_hide (priv->custom_warning_bin); + } else { + gtk_widget_set_sensitive (priv->params, FALSE); + gtk_widget_show (priv->params); + gtk_widget_hide (priv->custom_warning_bin); } } @@ -572,12 +545,10 @@ sensitize_buttons (RecurrencePage *rpage) else gtk_widget_set_sensitive (priv->params, FALSE); - gtk_widget_set_sensitive (priv->none, !read_only); - gtk_widget_set_sensitive (priv->simple, !read_only); + gtk_widget_set_sensitive (priv->recurs, !read_only); gtk_widget_set_sensitive (priv->exception_add, !read_only && e_cal_component_has_recurrences (priv->comp)); gtk_widget_set_sensitive (priv->exception_modify, !read_only && selected_rows > 0); gtk_widget_set_sensitive (priv->exception_delete, !read_only && selected_rows > 0); - gtk_widget_set_sensitive (priv->exception_date, !read_only); } #if 0 @@ -792,7 +763,7 @@ static gboolean fill_component (RecurrencePage *rpage, ECalComponent *comp) { RecurrencePagePrivate *priv; - enum recur_type recur_type; + gboolean recurs; GtkTreeModel *model; GtkTreeIter iter; gboolean valid_iter; @@ -801,27 +772,18 @@ fill_component (RecurrencePage *rpage, ECalComponent *comp) priv = rpage->priv; model = GTK_TREE_MODEL (priv->exception_list_store); - recur_type = e_dialog_radio_get (priv->none, type_map); - - switch (recur_type) { - case RECUR_NONE: + recurs = e_dialog_toggle_get (priv->recurs); + + if (recurs && priv->custom) { + /* We just keep whatever the component has currently */ + } else if (recurs) { e_cal_component_set_rdate_list (comp, NULL); - e_cal_component_set_rrule_list (comp, NULL); e_cal_component_set_exrule_list (comp, NULL); - break; - - case RECUR_SIMPLE: + simple_recur_to_comp (rpage, comp); + } else { e_cal_component_set_rdate_list (comp, NULL); + e_cal_component_set_rrule_list (comp, NULL); e_cal_component_set_exrule_list (comp, NULL); - simple_recur_to_comp (rpage, comp); - break; - - case RECUR_CUSTOM: - /* We just keep whatever the component has currently */ - break; - - default: - g_assert_not_reached (); } /* Set exceptions */ @@ -1558,7 +1520,6 @@ recurrence_page_fill_widgets (CompEditorPage *page, ECalComponent *comp) /* Summary */ e_cal_component_get_summary (comp, &text); - recurrence_page_set_summary (page, text.value); /* Dates */ comp_editor_dates (&dates, comp); @@ -1576,21 +1537,9 @@ recurrence_page_fill_widgets (CompEditorPage *page, ECalComponent *comp) if (!e_cal_component_has_rdates (comp) && !e_cal_component_has_rrules (comp) && !e_cal_component_has_exrules (comp)) { - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->none), - rpage); - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->simple), - rpage); - gtk_signal_handler_block_by_data (GTK_OBJECT (priv->custom), - rpage); - e_dialog_radio_set (priv->none, RECUR_NONE, type_map); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->none), - rpage); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->simple), - rpage); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->custom), - rpage); - - gtk_widget_set_sensitive (priv->custom, FALSE); + gtk_signal_handler_block_by_data (GTK_OBJECT (priv->recurs), rpage); + e_dialog_toggle_set (priv->recurs, FALSE); + gtk_signal_handler_unblock_by_data (GTK_OBJECT (priv->recurs), rpage); sensitize_buttons (rpage); preview_recur (rpage); @@ -1850,15 +1799,9 @@ recurrence_page_fill_widgets (CompEditorPage *page, ECalComponent *comp) /* If we got here it means it is a simple recurrence */ - g_signal_handlers_block_matched (priv->none, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, rpage); - g_signal_handlers_block_matched (priv->simple, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, rpage); - g_signal_handlers_block_matched (priv->custom, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, rpage); - e_dialog_radio_set (priv->simple, RECUR_SIMPLE, type_map); - g_signal_handlers_unblock_matched (priv->none, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, rpage); - g_signal_handlers_unblock_matched (priv->simple, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, rpage); - g_signal_handlers_unblock_matched (priv->custom, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, rpage); - - gtk_widget_set_sensitive (priv->custom, FALSE); + g_signal_handlers_block_matched (priv->recurs, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, rpage); + e_dialog_toggle_set (priv->recurs, TRUE); + g_signal_handlers_unblock_matched (priv->recurs, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, rpage); sensitize_buttons (rpage); make_recurrence_special (rpage); @@ -1874,19 +1817,16 @@ recurrence_page_fill_widgets (CompEditorPage *page, ECalComponent *comp) custom: - g_signal_handlers_block_matched (priv->none, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, rpage); - g_signal_handlers_block_matched (priv->simple, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, rpage); - g_signal_handlers_block_matched (priv->custom, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, rpage); - e_dialog_radio_set (priv->custom, RECUR_CUSTOM, type_map); - g_signal_handlers_unblock_matched (priv->none, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, rpage); - g_signal_handlers_unblock_matched (priv->simple, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, rpage); - g_signal_handlers_unblock_matched (priv->custom, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, rpage); + g_signal_handlers_block_matched (priv->recurs, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, rpage); + priv->custom = TRUE; + e_dialog_toggle_set (priv->recurs, TRUE); + g_signal_handlers_unblock_matched (priv->recurs, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, rpage); + /* FIXME Desensitize recurrence page */ - gtk_widget_set_sensitive (priv->custom, TRUE); sensitize_buttons (rpage); out: - + priv->custom = FALSE; e_cal_component_free_recur_list (rrule_list); preview_recur (rpage); @@ -1905,19 +1845,6 @@ recurrence_page_fill_component (CompEditorPage *page, ECalComponent *comp) return fill_component (rpage, comp); } -/* set_summary handler for the recurrence page */ -static void -recurrence_page_set_summary (CompEditorPage *page, const char *summary) -{ - RecurrencePage *rpage; - RecurrencePagePrivate *priv; - - rpage = RECURRENCE_PAGE (page); - priv = rpage->priv; - - gtk_label_set_text (GTK_LABEL (priv->summary), summary); -} - /* set_dates handler for the recurrence page */ static void recurrence_page_set_dates (CompEditorPage *page, CompEditorPageDates *dates) @@ -1931,8 +1858,6 @@ recurrence_page_set_dates (CompEditorPage *page, CompEditorPageDates *dates) rpage = RECURRENCE_PAGE (page); priv = rpage->priv; - comp_editor_date_label (dates, priv->date_time); - /* Copy the dates to our component */ if (!priv->comp) @@ -2000,13 +1925,8 @@ get_widgets (RecurrencePage *rpage) gtk_widget_ref (priv->main); gtk_container_remove (GTK_CONTAINER (priv->main->parent), priv->main); - - priv->summary = GW ("summary"); - priv->date_time = GW ("date-time"); - priv->none = GW ("none"); - priv->simple = GW ("simple"); - priv->custom = GW ("custom"); + priv->recurs = GW ("recurs"); priv->params = GW ("params"); priv->interval_value = GW ("interval-value"); @@ -2016,8 +1936,6 @@ get_widgets (RecurrencePage *rpage) priv->ending_special = GW ("ending-special"); priv->custom_warning_bin = GW ("custom-warning-bin"); - priv->exception_date = GW ("exception-date"); - gtk_widget_show (priv->exception_date); priv->exception_list = GW ("exception-list"); priv->exception_add = GW ("exception-add"); priv->exception_modify = GW ("exception-modify"); @@ -2027,11 +1945,7 @@ get_widgets (RecurrencePage *rpage) #undef GW - return (priv->summary - && priv->date_time - && priv->none - && priv->simple - && priv->custom + return (priv->recurs && priv->params && priv->interval_value && priv->interval_unit @@ -2039,7 +1953,6 @@ get_widgets (RecurrencePage *rpage) && priv->ending_menu && priv->ending_special && priv->custom_warning_bin - && priv->exception_date && priv->exception_list && priv->exception_add && priv->exception_modify @@ -2075,19 +1988,16 @@ type_toggled_cb (GtkToggleButton *toggle, gpointer data) field_changed (rpage); - if (toggle->active) { - sensitize_buttons (rpage); - preview_recur (rpage); - } + sensitize_buttons (rpage); + preview_recur (rpage); /* enable/disable the 'Add' button */ if (!e_cal_is_read_only (COMP_EDITOR_PAGE (rpage)->client, &read_only, NULL)) read_only = TRUE; - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->none)) || read_only) + if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->recurs)) || read_only) gtk_widget_set_sensitive (priv->exception_add, FALSE); - else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->simple)) || - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->custom))) + else gtk_widget_set_sensitive (priv->exception_add, TRUE); } @@ -2133,35 +2043,65 @@ ending_selection_done_cb (GtkMenuShell *menu_shell, gpointer data) preview_recur (rpage); } +static GtkWidget * +create_exception_dialog (RecurrencePage *rpage, const char *title, GtkWidget **date_edit) +{ + RecurrencePagePrivate *priv; + GtkWidget *dialog, *toplevel; + + priv = rpage->priv; + + toplevel = gtk_widget_get_toplevel (priv->main); + dialog = gtk_dialog_new_with_buttons (title, GTK_WINDOW (toplevel), + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, + GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, + NULL); + + *date_edit = comp_editor_new_date_edit (TRUE, FALSE, TRUE); + gtk_widget_show (*date_edit); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), *date_edit, FALSE, TRUE, 6); + + return dialog; +} + /* Callback for the "add exception" button */ static void exception_add_cb (GtkWidget *widget, gpointer data) { RecurrencePage *rpage; RecurrencePagePrivate *priv; - ECalComponentDateTime dt; - struct icaltimetype icaltime = icaltime_null_time (); + GtkWidget *dialog, *date_edit; gboolean date_set; - + rpage = RECURRENCE_PAGE (data); priv = rpage->priv; - field_changed (rpage); - - dt.value = &icaltime; - - /* We use DATE values for exceptions, so we don't need a TZID. */ - dt.tzid = NULL; - icaltime.is_date = 1; - - date_set = e_date_edit_get_date (E_DATE_EDIT (priv->exception_date), - &icaltime.year, - &icaltime.month, - &icaltime.day); - g_assert (date_set); + dialog = create_exception_dialog (rpage, "Add exception", &date_edit); + + if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) { + ECalComponentDateTime dt; + struct icaltimetype icaltime = icaltime_null_time (); - append_exception (rpage, &dt); - preview_recur (rpage); + field_changed (rpage); + + dt.value = &icaltime; + + /* We use DATE values for exceptions, so we don't need a TZID. */ + dt.tzid = NULL; + icaltime.is_date = 1; + + date_set = e_date_edit_get_date (E_DATE_EDIT (date_edit), + &icaltime.year, + &icaltime.month, + &icaltime.day); + g_assert (date_set); + + append_exception (rpage, &dt); + preview_recur (rpage); + } + + gtk_widget_destroy (dialog); } /* Callback for the "modify exception" button */ @@ -2170,10 +2110,9 @@ exception_modify_cb (GtkWidget *widget, gpointer data) { RecurrencePage *rpage; RecurrencePagePrivate *priv; + GtkWidget *dialog, *date_edit; + const ECalComponentDateTime *current_dt; GtkTreeSelection *selection; - ECalComponentDateTime dt; - struct icaltimetype icaltime = icaltime_null_time (); - struct icaltimetype *tt; GtkTreeIter iter; rpage = RECURRENCE_PAGE (data); @@ -2184,22 +2123,37 @@ exception_modify_cb (GtkWidget *widget, gpointer data) g_warning ("Could not get a selection to modify."); return; } - field_changed (rpage); - dt.value = &icaltime; - tt = dt.value; - e_date_edit_get_date (E_DATE_EDIT (priv->exception_date), - &tt->year, &tt->month, &tt->day); - tt->hour = 0; - tt->minute = 0; - tt->second = 0; - tt->is_date = 1; - - /* No TZID, since we are using a DATE value now. */ - dt.tzid = NULL; - - e_date_time_list_set_date_time (priv->exception_list_store, &iter, &dt); - preview_recur (rpage); + current_dt = e_date_time_list_get_date_time (priv->exception_list_store, &iter); + + dialog = create_exception_dialog (rpage, "Modify exception", &date_edit); + e_date_edit_set_date (E_DATE_EDIT (date_edit), + current_dt->value->year, current_dt->value->month, current_dt->value->day); + + if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) { + ECalComponentDateTime dt; + struct icaltimetype icaltime = icaltime_null_time (); + struct icaltimetype *tt; + + field_changed (rpage); + + dt.value = &icaltime; + tt = dt.value; + e_date_edit_get_date (E_DATE_EDIT (date_edit), + &tt->year, &tt->month, &tt->day); + tt->hour = 0; + tt->minute = 0; + tt->second = 0; + tt->is_date = 1; + + /* No TZID, since we are using a DATE value now. */ + dt.tzid = NULL; + + e_date_time_list_set_date_time (priv->exception_list_store, &iter, &dt); + preview_recur (rpage); + } + + gtk_widget_destroy (dialog); } /* Callback for the "delete exception" button */ @@ -2250,8 +2204,6 @@ exception_selection_changed_cb (GtkTreeSelection *selection, gpointer data) { RecurrencePage *rpage; RecurrencePagePrivate *priv; - const ECalComponentDateTime *dt; - struct icaltimetype *t; GtkTreeIter iter; rpage = RECURRENCE_PAGE (data); @@ -2265,16 +2217,6 @@ exception_selection_changed_cb (GtkTreeSelection *selection, gpointer data) gtk_widget_set_sensitive (priv->exception_modify, TRUE); gtk_widget_set_sensitive (priv->exception_delete, TRUE); - - dt = e_date_time_list_get_date_time (priv->exception_list_store, &iter); - g_assert (dt != NULL); - - t = dt->value; - - e_date_edit_set_date (E_DATE_EDIT (priv->exception_date), - t->year, t->month, t->day); - e_date_edit_set_time_of_day (E_DATE_EDIT (priv->exception_date), - t->hour, t->minute); } /* This is called when any field is changed; it notifies upstream. */ @@ -2315,24 +2257,13 @@ init_widgets (RecurrencePage *rpage) priv->preview_calendar); gtk_widget_show (priv->preview_calendar); - /* Make sure the EDateEdit widgets and ECalendarItem use our timezones - to get the current time. */ - e_date_edit_set_show_time (E_DATE_EDIT (priv->exception_date), FALSE); - e_date_edit_set_get_time_callback (E_DATE_EDIT (priv->exception_date), - (EDateEditGetTimeCallback) comp_editor_get_current_time, - rpage, NULL); e_calendar_item_set_get_time_callback (ecal->calitem, (ECalendarItemGetTimeCallback) comp_editor_get_current_time, rpage, NULL); /* Recurrence types */ - g_signal_connect((priv->none), "toggled", - G_CALLBACK (type_toggled_cb), rpage); - g_signal_connect((priv->simple), "toggled", - G_CALLBACK (type_toggled_cb), rpage); - g_signal_connect((priv->custom), "toggled", - G_CALLBACK (type_toggled_cb), rpage); + g_signal_connect(priv->recurs, "toggled", G_CALLBACK (type_toggled_cb), rpage); /* Recurrence interval */ diff --git a/calendar/gui/dialogs/recurrence-page.glade b/calendar/gui/dialogs/recurrence-page.glade index c5c2158979..107771e453 100644 --- a/calendar/gui/dialogs/recurrence-page.glade +++ b/calendar/gui/dialogs/recurrence-page.glade @@ -10,6 +10,11 @@ False True False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST @@ -19,122 +24,36 @@ 6 - + True - 0 - 0.5 - GTK_SHADOW_ETCHED_IN - - - - 6 - True - 2 - 2 - False - 6 - 6 - - - - True - Summary: - False - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 0 - 1 - fill - - - - - - - True - Date/Time: - False - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 1 - 2 - fill - - - - - - - True - - False - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 4 - 0 - - - 1 - 2 - 0 - 1 - - - + <b>Recurrence</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + - - - True - - False - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 4 - 0 - - - 1 - 2 - 1 - 2 - - - - - + + + True + False + 0 - + True - Basics + False False GTK_JUSTIFY_LEFT @@ -142,57 +61,66 @@ False 0.5 0.5 - 0 + 12 0 - label_item + 0 + False + False - - - 0 - False - False - - - - - - True - False - 0 - + True - 0 - 0.5 - GTK_SHADOW_ETCHED_IN + False + 6 - - 6 + + True + True + This appointment _recurs + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + True False 6 - + True False - 6 + 2 - + True - True - _No recurrence - True - GTK_RELIEF_NORMAL - False - False - True + Every + False + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 0 @@ -202,16 +130,16 @@ - + True True - _Simple recurrence - True - GTK_RELIEF_NORMAL - False - False - True - none + 1 + 0 + True + GTK_UPDATE_ALWAYS + False + False + 1 1 10000 1 10 10 0 @@ -221,16 +149,48 @@ - + True True - _Custom recurrence - True - GTK_RELIEF_NORMAL - False - False - True - none + 0 + + + + True + + + + True + day(s) + True + + + + + + True + week(s) + True + + + + + + True + month(s) + True + + + + + + True + year(s) + True + + + + 0 @@ -238,196 +198,64 @@ False - - - 0 - False - False - - - - - - True - False - 6 - + True - False - 2 + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 - - True - Every - False - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - - - 0 - False - False - + + + + 0 + False + False + + - - - True - True - 1 - 0 - True - GTK_UPDATE_ALWAYS - False - False - 1 1 10000 1 10 10 - - - 0 - False - False - - + + + True + True + 0 - - + + True - True - 0 - - + + True - - - - True - day(s) - True - - - - - - True - week(s) - True - - - - - - True - month(s) - True - - - - - - True - year(s) - True - - + for + True - - - 0 - False - False - - - - - - True - 0.5 - 0.5 - 0 - 0 - - - - - 0 - False - False - - - - - - True - True - 0 - - - + True - - - - True - for - True - - - - - - True - until - True - - - - - - True - forever - True - - + until + True - - - 0 - False - False - - - - - - True - 0.5 - 0.5 - 0 - 0 - + + True + forever + True + - - 0 - False - False - @@ -438,12 +266,16 @@ - + True - 0 + 0.5 0.5 - 1 - 1 + 0 + 0 + 0 + 0 + 0 + 0 @@ -451,8 +283,8 @@ 0 - True - True + False + False @@ -462,25 +294,34 @@ False - - - - - True - Recurrence Rule - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 + + + True + 0 + 0.5 + 1 + 1 + 0 + 0 + 0 + 0 + + + + + + + 0 + True + True + + - label_item + 0 + True + True @@ -490,217 +331,289 @@ False + + + 0 + False + True + + + + + + True + <b>Exceptions</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + False + 0 - + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 12 + 0 + + + 0 + False + False + + + + + True False 6 - + True - 0 - 0.5 - GTK_SHADOW_ETCHED_IN + GTK_POLICY_NEVER + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT - - 6 + True - False - 6 - - - - True - False - 4 + True + False + False + False + True + + + + + 0 + True + True + + - - - True - True - A_dd - True - GTK_RELIEF_NORMAL - - - 0 - False - False - - + + + True + GTK_BUTTONBOX_START + 6 - - - True - True - _Modify - True - GTK_RELIEF_NORMAL - - - 0 - False - False - - + + + True + True + True + gtk-add + True + GTK_RELIEF_NORMAL + True + + - - - True - True - _Remove - True - GTK_RELIEF_NORMAL - - - 0 - False - False - - - - - 0 - False - False - - + + + True + True + True + GTK_RELIEF_NORMAL + True - + True - False - 6 + 0.5 + 0.5 + 0 + 0 + 0 + 0 + 0 + 0 - + True - make_exdate_date_edit - 0 - 0 - Tue, 16 May 2000 01:42:29 GMT - - - 0 - False - False - - + False + 2 - - - True - GTK_POLICY_NEVER - GTK_POLICY_AUTOMATIC - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT + + + True + gtk-preferences + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + - + True - True - True - False - False - True + _Edit + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + 0 + False + False + - - 0 - True - True - - - 0 - True - True - - + True - Exceptions - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 + True + True + gtk-remove + True + GTK_RELIEF_NORMAL + True - - label_item - 0 - True + False True + + + 0 + True + True + + + + + 0 + True + True + + + + + + True + <b>Preview</b> + False + True + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + False + 0 + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 12 + 0 + + + 0 + False + False + + + + + + True + False + 0 - + True - False - 6 - - - - True - Preview - False - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - - - 0 - False - False - - + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 - - True - 0 - 0 - 1 - 1 - - - - - - - 0 - True - True - + 0 False - False + True diff --git a/calendar/gui/dialogs/task-details-page.c b/calendar/gui/dialogs/task-details-page.c index 6c8dcbba32..029ba07929 100644 --- a/calendar/gui/dialogs/task-details-page.c +++ b/calendar/gui/dialogs/task-details-page.c @@ -277,6 +277,25 @@ clear_widgets (TaskDetailsPage *tdpage) e_dialog_editable_set (priv->url, NULL); } +static void +sensitize_widgets (TaskDetailsPage *tdpage) +{ + gboolean read_only; + TaskDetailsPagePrivate *priv; + + priv = tdpage->priv; + + if (!e_cal_is_read_only (COMP_EDITOR_PAGE (tdpage)->client, &read_only, NULL)) + read_only = TRUE; + + gtk_widget_set_sensitive (priv->status, !read_only); + gtk_widget_set_sensitive (priv->priority, !read_only); + gtk_widget_set_sensitive (priv->percent_complete, !read_only); + gtk_widget_set_sensitive (priv->completed_date, !read_only); + gtk_widget_set_sensitive (priv->url_label, !read_only); + gtk_entry_set_editable (GTK_ENTRY (e_url_entry_get_entry (priv->url_entry)), !read_only); +} + /* fill_widgets handler for the task page */ static gboolean task_details_page_fill_widgets (CompEditorPage *page, ECalComponent *comp) @@ -363,6 +382,8 @@ task_details_page_fill_widgets (CompEditorPage *page, ECalComponent *comp) priv->updating = FALSE; + sensitize_widgets (tdpage); + return TRUE; } @@ -729,7 +750,13 @@ init_widgets (TaskDetailsPage *tdpage) G_CALLBACK (field_changed_cb), tdpage); } - +static void +client_changed_cb (CompEditorPage *page, ECal *client, gpointer user_data) +{ + TaskDetailsPage *tdpage = TASK_DETAILS_PAGE (page); + + sensitize_widgets (tdpage); +} /** * task_details_page_construct: @@ -763,6 +790,9 @@ task_details_page_construct (TaskDetailsPage *tdpage) init_widgets (tdpage); + g_signal_connect_after (G_OBJECT (tdpage), "client_changed", + G_CALLBACK (client_changed_cb), NULL); + return tdpage; } diff --git a/calendar/gui/dialogs/task-details-page.glade b/calendar/gui/dialogs/task-details-page.glade index 8cd357c4d3..5396696733 100644 --- a/calendar/gui/dialogs/task-details-page.glade +++ b/calendar/gui/dialogs/task-details-page.glade @@ -10,6 +10,11 @@ False True False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST @@ -19,297 +24,313 @@ 6 - + True - 0 - 0.5 - GTK_SHADOW_ETCHED_IN + <span weight="bold">Status</span> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + False + 0 - - 6 + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 12 + 0 + + + 0 + False + False + + + + + + True + 4 + 2 False - 6 + 6 + 12 - - 4 + True - False - 6 + _Status: + True + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + status + + + 0 + 1 + 0 + 1 + fill + + + - - - True - _Status: - True - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 - status - - - 0 - False - False - - + + + True + P_ercent complete: + True + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + percent-complete + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + _Priority: + True + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + priority + + + 0 + 1 + 2 + 3 + fill + + + - - + + + True + _Date completed: + True + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 3 + 4 + fill + + + + + + + True + True + 0 + + + True - True - 0 - - + + True + High + True + + - - - True - Not Started - True - - - - - - True - In Progress - True - - - - - - True - Completed - True - - - - - - True - Cancelled - True - - + + + True + Normal + True - - - 0 - False - False - - - - - True - _Priority: - True - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 - priority + + + True + Low + True + + + + + + True + Undefined + True + + - - 0 - False - False - + + + 1 + 2 + 2 + 3 + fill + + + - - + + + True + True + 0 + + + True - True - 0 - - + + True + Not Started + True + + - - - True - High - True - - - - - - True - Normal - True - - - - - - True - Low - True - - - - - - True - Undefined - True - - + + + True + In Progress + True - - - 0 - False - False - - - - - True - % _Complete - True - False - GTK_JUSTIFY_CENTER - False - False - 0.5 - 0.5 - 0 - 0 - percent-complete - - - 0 - False - False - - + + + True + Completed + True + + - - - True - True - 1 - 0 - True - GTK_UPDATE_ALWAYS - False - False - 1 0 100 1 10 10 + + + True + Cancelled + True + + - - 0 - True - True - - 0 - True - True + 1 + 2 + 0 + 1 + fill + - - 4 + True - 1 - 2 - False - 2 - 4 - - - - True - _Date completed: - True - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - - - 0 - 1 - 0 - 1 - fill - - - - - - - True - task_details_page_create_date_edit - 0 - 0 - Fri, 01 Jun 2001 18:58:51 GMT - - - 1 - 2 - 0 - 1 - fill - fill - - + True + 1 + 0 + True + GTK_UPDATE_ALWAYS + False + False + 0 0 100 1 10 10 - 0 - True - True + 1 + 2 + 1 + 2 + fill + - - - - - True - Progress - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 + + + True + task_details_page_create_date_edit + 0 + 0 + Fri, 01 Jun 2001 18:58:51 GMT + + + 1 + 2 + 3 + 4 + fill + + + - label_item + 0 + True + True @@ -321,59 +342,114 @@ - - 6 + + True + <span weight="bold">Miscellaneous </span> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + True - 1 - 2 False - 6 - 6 + 0 - + True - _Web Page: - True + + False False - GTK_JUSTIFY_CENTER + GTK_JUSTIFY_LEFT False False - 0 + 0.5 0.5 - 0 + 12 0 - 0 - 1 - 0 - 1 - fill - + 0 + False + False - + + 6 True - e_url_entry_new - 0 - 0 - Fri, 08 Feb 2002 21:02:37 GMT + 1 + 2 + False + 6 + 6 + + + + True + _Web Page: + True + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + e_url_entry_new + 0 + 0 + Fri, 08 Feb 2002 21:02:37 GMT + + + 1 + 2 + 0 + 1 + fill + + - 1 - 2 - 0 - 1 - fill + 0 + True + True 0 - False + True True diff --git a/calendar/gui/dialogs/task-editor.c b/calendar/gui/dialogs/task-editor.c index 972651b6c8..2023e1dcd8 100644 --- a/calendar/gui/dialogs/task-editor.c +++ b/calendar/gui/dialogs/task-editor.c @@ -63,15 +63,6 @@ static void forward_cmd (GtkWidget *widget, gpointer data); static void model_row_change_insert_cb (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data); static void model_row_delete_cb (GtkTreeModel *model, GtkTreePath *path, gpointer data); -static BonoboUIVerb verbs [] = { - BONOBO_UI_UNSAFE_VERB ("ActionAssignTask", assign_task_cmd), - BONOBO_UI_UNSAFE_VERB ("ActionRefreshTask", refresh_task_cmd), - BONOBO_UI_UNSAFE_VERB ("ActionCancelTask", cancel_task_cmd), - BONOBO_UI_UNSAFE_VERB ("ActionForward", forward_cmd), - - BONOBO_UI_VERB_END -}; - static CompEditorClass *parent_class; @@ -107,47 +98,6 @@ task_editor_class_init (TaskEditorClass *klass) object_class->finalize = task_editor_finalize; } -static void -set_menu_sens (TaskEditor *te) -{ - TaskEditorPrivate *priv; - gboolean sens, existing, user, read_only = TRUE; - - priv = te->priv; - - existing = comp_editor_get_existing_org (COMP_EDITOR (te)); - user = comp_editor_get_user_org (COMP_EDITOR (te)); - - e_cal_is_read_only (comp_editor_get_e_cal (COMP_EDITOR (te)), &read_only, NULL); - - sens = e_cal_get_static_capability (comp_editor_get_e_cal (COMP_EDITOR (te)), - CAL_STATIC_CAPABILITY_NO_TASK_ASSIGNMENT) - || priv->assignment_shown || read_only; - comp_editor_set_ui_prop (COMP_EDITOR (te), - "/commands/ActionAssignTask", - "sensitive", sens ? "0" : "1"); - - sens = priv->assignment_shown && existing && !user && !read_only; - comp_editor_set_ui_prop (COMP_EDITOR (te), - "/commands/ActionRefreshTask", - "sensitive", sens ? "1" : "0"); - - sens = priv->assignment_shown && existing && user && !read_only; - comp_editor_set_ui_prop (COMP_EDITOR (te), - "/commands/ActionCancelTask", - "sensitive", sens ? "1" : "0"); - - comp_editor_set_ui_prop (COMP_EDITOR (te), - "/commands/FileSave", - "sensitive", read_only ? "0" : "1"); - comp_editor_set_ui_prop (COMP_EDITOR (te), - "/commands/FileSaveAndClose", - "sensitive", read_only ? "0" : "1"); - comp_editor_set_ui_prop (COMP_EDITOR (te), - "/commands/FileDelete", - "sensitive", read_only ? "0" : "1"); -} - static void init_widgets (TaskEditor *te) { @@ -166,7 +116,7 @@ init_widgets (TaskEditor *te) static void client_changed_cb (CompEditorPage *page, ECal *client, gpointer user_data) { - set_menu_sens (TASK_EDITOR (user_data)); +// set_menu_sens (TASK_EDITOR (user_data)); } /* Object initialization function for the task editor */ @@ -196,7 +146,7 @@ task_editor_construct (TaskEditor *te, ECal *client) gtk_object_sink (GTK_OBJECT (priv->task_page)); comp_editor_append_page (COMP_EDITOR (te), COMP_EDITOR_PAGE (priv->task_page), - _("Basic")); + _("Basics")); g_signal_connect (G_OBJECT (priv->task_page), "client_changed", G_CALLBACK (client_changed_cb), te); @@ -205,7 +155,7 @@ task_editor_construct (TaskEditor *te, ECal *client) gtk_object_sink (GTK_OBJECT (priv->task_details_page)); comp_editor_append_page (COMP_EDITOR (te), COMP_EDITOR_PAGE (priv->task_details_page), - _("Details")); + _("Status")); priv->meet_page = meeting_page_new (priv->model, client); g_object_ref (priv->meet_page); @@ -216,10 +166,7 @@ task_editor_construct (TaskEditor *te, ECal *client) comp_editor_set_e_cal (COMP_EDITOR (te), client); - comp_editor_merge_ui (COMP_EDITOR (te), "evolution-task-editor.xml", verbs, NULL); - init_widgets (te); - set_menu_sens (te); return te; } @@ -319,7 +266,6 @@ task_editor_edit_comp (CompEditor *editor, ECalComponent *comp) } e_cal_component_free_attendee_list (attendees); - set_menu_sens (te); comp_editor_set_needs_send (COMP_EDITOR (te), priv->assignment_shown && itip_organizer_is_user (comp, client)); priv->updating = FALSE; @@ -415,7 +361,6 @@ show_assignment (TaskEditor *te) _("Assignment")); priv->assignment_shown = TRUE; - set_menu_sens (te); comp_editor_set_needs_send (COMP_EDITOR (te), priv->assignment_shown); comp_editor_set_changed (COMP_EDITOR (te), TRUE); } diff --git a/calendar/gui/dialogs/task-page.c b/calendar/gui/dialogs/task-page.c index de17834994..3199ef7260 100644 --- a/calendar/gui/dialogs/task-page.c +++ b/calendar/gui/dialogs/task-page.c @@ -57,6 +57,7 @@ struct _TaskPagePrivate { GtkWidget *main; GtkWidget *summary; + GtkWidget *summary_label; GtkWidget *due_date; GtkWidget *start_date; @@ -65,9 +66,7 @@ struct _TaskPagePrivate { GtkWidget *description; - GtkWidget *classification_public; - GtkWidget *classification_private; - GtkWidget *classification_confidential; + GtkWidget *classification; GtkWidget *categories_btn; GtkWidget *categories; @@ -150,14 +149,13 @@ task_page_init (TaskPage *tpage) priv->main = NULL; priv->summary = NULL; + priv->summary_label = NULL; priv->due_date = NULL; priv->start_date = NULL; priv->due_timezone = NULL; priv->start_timezone = NULL; priv->description = NULL; - priv->classification_public = NULL; - priv->classification_private = NULL; - priv->classification_confidential = NULL; + priv->classification = NULL; priv->categories_btn = NULL; priv->categories = NULL; @@ -237,8 +235,7 @@ clear_widgets (TaskPage *tpage) e_date_edit_set_time (E_DATE_EDIT (priv->due_date), 0); /* Classification */ - e_dialog_radio_set (priv->classification_public, - E_CAL_COMPONENT_CLASS_PRIVATE, classification_map); + e_dialog_option_menu_set (priv->classification, E_CAL_COMPONENT_CLASS_PRIVATE, classification_map); /* Categories */ e_dialog_editable_set (priv->categories, NULL); @@ -248,7 +245,30 @@ clear_widgets (TaskPage *tpage) static ECalComponentClassification classification_get (GtkWidget *widget) { - return e_dialog_radio_get (widget, classification_map); + return e_dialog_option_menu_get (widget, classification_map); +} + +static void +sensitize_widgets (TaskPage *tpage) +{ + gboolean read_only; + TaskPagePrivate *priv; + + priv = tpage->priv; + + if (!e_cal_is_read_only (COMP_EDITOR_PAGE (tpage)->client, &read_only, NULL)) + read_only = TRUE; + + gtk_widget_set_sensitive (priv->summary_label, !read_only); + gtk_entry_set_editable (GTK_ENTRY (priv->summary), !read_only); + gtk_widget_set_sensitive (priv->due_date, !read_only); + gtk_widget_set_sensitive (priv->start_date, !read_only); + gtk_widget_set_sensitive (priv->due_timezone, !read_only); + gtk_widget_set_sensitive (priv->start_timezone, !read_only); + gtk_widget_set_sensitive (priv->description, !read_only); + gtk_widget_set_sensitive (priv->classification, !read_only); + gtk_widget_set_sensitive (priv->categories_btn, !read_only); + gtk_entry_set_editable (GTK_ENTRY (priv->categories), !read_only); } /* fill_widgets handler for the task page */ @@ -379,30 +399,15 @@ task_page_fill_widgets (CompEditorPage *page, ECalComponent *comp) switch (cl) { case E_CAL_COMPONENT_CLASS_PUBLIC: - e_dialog_radio_set (priv->classification_public, - E_CAL_COMPONENT_CLASS_PUBLIC, - classification_map); - break; - case E_CAL_COMPONENT_CLASS_PRIVATE: - e_dialog_radio_set (priv->classification_public, - E_CAL_COMPONENT_CLASS_PRIVATE, - classification_map); - break; - case E_CAL_COMPONENT_CLASS_CONFIDENTIAL: - e_dialog_radio_set (priv->classification_public, - E_CAL_COMPONENT_CLASS_CONFIDENTIAL, - classification_map); break; - default: /* default to PUBLIC */ - e_dialog_radio_set (priv->classification_public, - E_CAL_COMPONENT_CLASS_PUBLIC, - classification_map); + cl = E_CAL_COMPONENT_CLASS_PUBLIC; break; } + e_dialog_option_menu_set (priv->classification, cl, classification_map); /* Categories */ e_cal_component_get_categories (comp, &categories); @@ -414,6 +419,8 @@ task_page_fill_widgets (CompEditorPage *page, ECalComponent *comp) priv->updating = FALSE; + sensitize_widgets (tpage); + return TRUE; } @@ -540,7 +547,7 @@ task_page_fill_component (CompEditorPage *page, ECalComponent *comp) } /* Classification. */ - e_cal_component_set_classification (comp, classification_get (priv->classification_public)); + e_cal_component_set_classification (comp, classification_get (priv->classification)); /* Categories */ cat = e_dialog_editable_get (priv->categories); @@ -640,6 +647,7 @@ get_widgets (TaskPage *tpage) gtk_container_remove (GTK_CONTAINER (priv->main->parent), priv->main); priv->summary = GW ("summary"); + priv->summary_label = GW ("summary-label"); /* Glade's visibility flag doesn't seem to work for custom widgets */ priv->due_date = GW ("due-date"); @@ -652,9 +660,7 @@ get_widgets (TaskPage *tpage) priv->description = GW ("description"); - priv->classification_public = GW ("classification-public"); - priv->classification_private = GW ("classification-private"); - priv->classification_confidential = GW ("classification-confidential"); + priv->classification = GW ("classification"); priv->categories_btn = GW ("categories-button"); priv->categories = GW ("categories"); @@ -664,13 +670,12 @@ get_widgets (TaskPage *tpage) #undef GW return (priv->summary + && priv->summary_label && priv->due_date && priv->start_date && priv->due_timezone && priv->start_timezone - && priv->classification_public - && priv->classification_private - && priv->classification_confidential + && priv->classification && priv->description && priv->categories_btn && priv->categories); @@ -802,11 +807,11 @@ field_changed_cb (GtkWidget *widget, gpointer data) static void source_changed_cb (GtkWidget *widget, ESource *source, gpointer data) { - TaskPage *epage; + TaskPage *tpage; TaskPagePrivate *priv; - epage = TASK_PAGE (data); - priv = epage->priv; + tpage = TASK_PAGE (data); + priv = tpage->priv; if (!priv->updating) { ECal *client; @@ -819,7 +824,7 @@ source_changed_cb (GtkWidget *widget, ESource *source, gpointer data) g_object_unref (client); e_source_option_menu_select (E_SOURCE_OPTION_MENU (priv->source_selector), - e_cal_get_source (COMP_EDITOR_PAGE (epage)->client)); + e_cal_get_source (COMP_EDITOR_PAGE (tpage)->client)); dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, @@ -831,6 +836,7 @@ source_changed_cb (GtkWidget *widget, ESource *source, gpointer data) comp_editor_notify_client_changed ( COMP_EDITOR (gtk_widget_get_toplevel (priv->main)), client); + sensitize_widgets (tpage); } } } @@ -871,21 +877,13 @@ init_widgets (TaskPage *tpage) g_signal_connect((priv->due_date), "changed", G_CALLBACK (date_changed_cb), tpage); - g_signal_connect((priv->due_timezone), "changed", - G_CALLBACK (field_changed_cb), tpage); - g_signal_connect((priv->start_timezone), "changed", - G_CALLBACK (field_changed_cb), tpage); + /* Categories button */ + g_signal_connect((priv->categories_btn), "clicked", + G_CALLBACK (categories_clicked_cb), tpage); - /* Classification */ - g_signal_connect((priv->classification_public), - "toggled", - G_CALLBACK (field_changed_cb), tpage); - g_signal_connect((priv->classification_private), - "toggled", - G_CALLBACK (field_changed_cb), tpage); - g_signal_connect((priv->classification_confidential), - "toggled", - G_CALLBACK (field_changed_cb), tpage); + /* Source selector */ + g_signal_connect((priv->source_selector), "source_selected", + G_CALLBACK (source_changed_cb), tpage); /* Connect the default signal handler to use to make sure the "changed" field gets set whenever a field is changed. */ @@ -894,17 +892,17 @@ init_widgets (TaskPage *tpage) g_signal_connect ((text_buffer), "changed", G_CALLBACK (field_changed_cb), tpage); + g_signal_connect((priv->summary), "changed", + G_CALLBACK (field_changed_cb), tpage); + g_signal_connect((priv->due_timezone), "changed", + G_CALLBACK (field_changed_cb), tpage); + g_signal_connect((priv->start_timezone), "changed", + G_CALLBACK (field_changed_cb), tpage); + g_signal_connect((priv->classification), "changed", + G_CALLBACK (field_changed_cb), tpage); g_signal_connect((priv->categories), "changed", G_CALLBACK (field_changed_cb), tpage); - /* Categories button */ - g_signal_connect((priv->categories_btn), "clicked", - G_CALLBACK (categories_clicked_cb), tpage); - - /* Source selector */ - g_signal_connect((priv->source_selector), "source_selected", - G_CALLBACK (source_changed_cb), tpage); - /* Set the default timezone, so the timezone entry may be hidden. */ zone = calendar_config_get_icaltimezone (); e_timezone_entry_set_default_timezone (E_TIMEZONE_ENTRY (priv->start_timezone), zone); diff --git a/calendar/gui/dialogs/task-page.glade b/calendar/gui/dialogs/task-page.glade index 6f70da6b03..b914881118 100644 --- a/calendar/gui/dialogs/task-page.glade +++ b/calendar/gui/dialogs/task-page.glade @@ -10,6 +10,11 @@ False True False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST @@ -19,236 +24,335 @@ 6 - + + True + <span weight="bold">Basics</span> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + True - 1 - 2 False - 6 - 6 + 0 - + True - Su_mmary: - True + + False False - GTK_JUSTIFY_CENTER + GTK_JUSTIFY_LEFT False False 0.5 0.5 - 0 + 12 0 - summary - 0 - 1 - 0 - 1 - - + 0 + False + False - + True - True - True - True - 0 - - True - * - False - - - 1 - 2 - 0 - 1 - - - - - - 0 - False - True - - + 4 + 2 + False + 6 + 12 - - - True - 0 - 0.5 - GTK_SHADOW_ETCHED_IN + + + True + True + True + True + 0 + + True + * + False + + + 1 + 2 + 0 + 1 + + + - - - 6 - True - False - 6 + + + True + Su_mmary: + True + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + summary + + + 0 + 1 + 0 + 1 + fill + + + - + + True + Classi_fication: + True + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + classification + + + 0 + 1 + 1 + 2 + fill + + + + + + True - 2 - 3 False - 2 - 4 + 0 - + True - Sta_rt date: - True - False - GTK_JUSTIFY_CENTER - False - False - 0 - 0.5 - 0 - 0 - start-date + True + 0 + + + + + + + True + Public + True + + + + + + True + Private + True + + + + + + True + Confidential + True + + + + - 0 - 1 - 1 - 2 - fill - + 0 + True + True - + True - _Due date: + _Group: True False - GTK_JUSTIFY_CENTER + GTK_JUSTIFY_LEFT False False - 0 + 0.5 0.5 - 0 + 12 0 - due-date + source - 0 - 1 - 0 - 1 - fill - + 0 + False + False - + True - True - task_page_create_date_edit + task_page_create_source_option_menu 0 0 - Fri, 01 Jun 2001 18:59:52 GMT + Thu, 18 Dec 2003 01:58:48 GMT - 1 - 2 - 0 - 1 - + 0 + True + True + + + 1 + 2 + 1 + 2 + fill + fill + + - - - True - True - task_page_create_date_edit - 0 - 0 - Fri, 01 Jun 2001 18:59:57 GMT - - - 1 - 2 - 1 - 2 - - - + + + True + True + Ca_tegories... + True + GTK_RELIEF_NORMAL + True + + + 0 + 1 + 2 + 3 + fill + + + - - - True - make_timezone_entry - 0 - 0 - Tue, 19 Jun 2001 04:43:54 GMT - - - 2 - 3 - 0 - 1 - fill - - + + + True + True + True + True + 0 + + True + * + False + + + 1 + 2 + 2 + 3 + + + + + + + True + GTK_POLICY_NEVER + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT - + True - make_timezone_entry - 0 - 0 - Tue, 19 Jun 2001 04:43:46 GMT + True + True + False + True + GTK_JUSTIFY_LEFT + GTK_WRAP_WORD + True + 0 + 0 + 0 + 0 + 0 + 0 + - - 2 - 3 - 1 - 2 - fill - fill - - 0 - False - True + 1 + 2 + 3 + 4 + fill + fill - - - - - True - Date & Time - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 + + + True + Description: + False + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0 + 0 + 0 + description + + + 0 + 1 + 3 + 4 + fill + fill + + - label_item + 0 + True + True @@ -260,23 +364,44 @@ - + + True + <span weight="bold">Date and Time</span> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + True False - 6 + 0 - + True - Description: + False False - GTK_JUSTIFY_CENTER + GTK_JUSTIFY_LEFT False False - 0 + 0.5 0.5 - 0 + 12 0 @@ -287,175 +412,155 @@ - - True - GTK_POLICY_NEVER - GTK_POLICY_AUTOMATIC - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT - - - - True - True - True - GTK_JUSTIFY_LEFT - GTK_WRAP_WORD - True - 0 - 0 - 0 - 0 - 0 - 0 - - - - - - 0 - True - True - - - - - 0 - True - True - - - - - - True - 0 - 0.5 - GTK_SHADOW_ETCHED_IN - - - - 6 + True + 2 + 2 False - 6 + 6 + 12 - + True - True - Pu_blic + _Due date: True - GTK_RELIEF_NORMAL - True - False - True + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + due-date - 0 - False - False + 0 + 1 + 0 + 1 + fill + - + True - True - Pri_vate + Sta_rt date: True - GTK_RELIEF_NORMAL - False - False - True - classification-public + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + start-date - 0 - False - False + 0 + 1 + 1 + 2 + fill + - + True - True - Con_fidential - True - GTK_RELIEF_NORMAL - False - False - True - classification-public + False + 0 + + + + True + task_page_create_date_edit + 0 + 0 + Mon, 14 Jun 2004 18:16:07 GMT + + + 0 + True + True + + + + + + True + make_timezone_entry + 0 + 0 + Tue, 19 Jun 2001 04:43:54 GMT + + + 0 + True + True + + - 0 - False - False + 1 + 2 + 0 + 1 + fill + fill - - - - - True - Classification - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - label_item - - - - - 0 - False - True - - - - - - True - False - 6 + + + True + False + 0 - - - True - True - Ca_tegories... - True - GTK_RELIEF_NORMAL - - - 0 - False - False - - + + + True + task_page_create_date_edit + 0 + 0 + Mon, 14 Jun 2004 18:16:13 GMT + + + 0 + True + True + + - - - True - True - True - True - 0 - - True - * - False + + + True + make_timezone_entry + 0 + 0 + Tue, 19 Jun 2001 04:43:46 GMT + + + 0 + True + True + + + + + 1 + 2 + 1 + 2 + fill + fill + + 0 @@ -463,46 +568,10 @@ True - - - - True - Folder: - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - task_page_create_source_option_menu - 0 - 0 - Thu, 18 Dec 2003 01:58:48 GMT - - - 0 - False - True - - 0 - False + True True -- cgit v1.2.3