aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui
diff options
context:
space:
mode:
Diffstat (limited to 'calendar/gui')
-rw-r--r--calendar/gui/calendar-commands.c181
-rw-r--r--calendar/gui/e-day-view.c6
-rw-r--r--calendar/gui/e-week-view.c6
-rw-r--r--calendar/gui/gnome-cal.c346
-rw-r--r--calendar/gui/gnome-cal.h12
5 files changed, 461 insertions, 90 deletions
diff --git a/calendar/gui/calendar-commands.c b/calendar/gui/calendar-commands.c
index e3ddb5ce00..62c123da4a 100644
--- a/calendar/gui/calendar-commands.c
+++ b/calendar/gui/calendar-commands.c
@@ -62,6 +62,14 @@ static GList *all_calendars = NULL;
/* We have one global preferences dialog. */
static CalPrefsDialog *preferences_dialog = NULL;
+/* Focusing information for the calendar view. We have to keep track of this
+ * ourselves because with Bonobo controls, we may get unpaired focus_out events.
+ */
+typedef struct {
+ guint calendar_focused : 1;
+ guint taskpad_focused : 1;
+} FocusData;
+
/* Callback for the new appointment command */
static void
new_appointment_cb (BonoboUIComponent *uic, gpointer data, const char *path)
@@ -280,7 +288,7 @@ settings_cmd (BonoboUIComponent *uic, gpointer data, const char *path)
}
static void
-cut_event_cmd (BonoboUIComponent *uic, gpointer data, const gchar *path)
+cut_cmd (BonoboUIComponent *uic, gpointer data, const gchar *path)
{
GnomeCalendar *gcal;
@@ -291,7 +299,7 @@ cut_event_cmd (BonoboUIComponent *uic, gpointer data, const gchar *path)
}
static void
-copy_event_cmd (BonoboUIComponent *uic, gpointer data, const gchar *path)
+copy_cmd (BonoboUIComponent *uic, gpointer data, const gchar *path)
{
GnomeCalendar *gcal;
@@ -303,7 +311,7 @@ copy_event_cmd (BonoboUIComponent *uic, gpointer data, const gchar *path)
}
static void
-paste_event_cmd (BonoboUIComponent *uic, gpointer data, const gchar *path)
+paste_cmd (BonoboUIComponent *uic, gpointer data, const gchar *path)
{
GnomeCalendar *gcal;
@@ -315,14 +323,14 @@ paste_event_cmd (BonoboUIComponent *uic, gpointer data, const gchar *path)
}
static void
-delete_event_cmd (BonoboUIComponent *uic, gpointer data, const gchar *path)
+delete_cmd (BonoboUIComponent *uic, gpointer data, const gchar *path)
{
GnomeCalendar *gcal;
gcal = GNOME_CALENDAR (data);
set_clock_cursor (gcal);
- gnome_calendar_delete_event (gcal);
+ gnome_calendar_delete_selection (gcal);
set_normal_cursor (gcal);
}
@@ -504,11 +512,42 @@ control_util_set_folder_bar_label (BonoboControl *control, char *label)
CORBA_exception_free (&ev);
}
-/* Sensitizes the UI Component menu/toolbar commands based on the number of
- * selected events. (This will always be 0 or 1 currently.)
+/* Sensitizes the UI Component menu/toolbar calendar commands based on the
+ * number of selected events. (This will always be 0 or 1 currently.) If enable
+ * is FALSE, all will be disabled. Otherwise, the currently-selected number of
+ * events will be used.
+ */
+static void
+sensitize_calendar_commands (GnomeCalendar *gcal, BonoboControl *control, gboolean enable)
+{
+ BonoboUIComponent *uic;
+ int n_selected;
+
+ uic = bonobo_control_get_ui_component (control);
+ g_assert (uic != NULL);
+
+ n_selected = enable ? gnome_calendar_get_num_events_selected (gcal) : 0;
+
+ bonobo_ui_component_set_prop (uic, "/commands/Cut", "sensitive",
+ n_selected == 0 ? "0" : "1",
+ NULL);
+ bonobo_ui_component_set_prop (uic, "/commands/Copy", "sensitive",
+ n_selected == 0 ? "0" : "1",
+ NULL);
+ bonobo_ui_component_set_prop (uic, "/commands/Paste", "sensitive",
+ enable ? "1" : "0",
+ NULL);
+ bonobo_ui_component_set_prop (uic, "/commands/Delete", "sensitive",
+ n_selected == 0 ? "0" : "1",
+ NULL);
+}
+
+/* Sensitizes the UI Component menu/toolbar tasks commands based on the number
+ * of selected tasks. If enable is FALSE, all will be disabled. Otherwise, the
+ * currently-selected number of tasks will be used.
*/
static void
-sensitize_commands (GnomeCalendar *gcal, BonoboControl *control)
+sensitize_taskpad_commands (GnomeCalendar *gcal, BonoboControl *control, gboolean enable)
{
BonoboUIComponent *uic;
int n_selected;
@@ -516,30 +555,103 @@ sensitize_commands (GnomeCalendar *gcal, BonoboControl *control)
uic = bonobo_control_get_ui_component (control);
g_assert (uic != NULL);
- n_selected = gnome_calendar_get_num_events_selected (gcal);
+ n_selected = enable ? gnome_calendar_get_num_tasks_selected (gcal) : 0;
- bonobo_ui_component_set_prop (uic, "/commands/CutEvent", "sensitive",
+ bonobo_ui_component_set_prop (uic, "/commands/Cut", "sensitive",
n_selected == 0 ? "0" : "1",
NULL);
- bonobo_ui_component_set_prop (uic, "/commands/CopyEvent", "sensitive",
+ bonobo_ui_component_set_prop (uic, "/commands/Copy", "sensitive",
n_selected == 0 ? "0" : "1",
NULL);
- bonobo_ui_component_set_prop (uic, "/commands/DeleteEvent", "sensitive",
+ bonobo_ui_component_set_prop (uic, "/commands/Paste", "sensitive",
+ enable ? "1" : "0",
+ NULL);
+ bonobo_ui_component_set_prop (uic, "/commands/Delete", "sensitive",
n_selected == 0 ? "0" : "1",
NULL);
}
/* Callback used when the selection in the calendar views changes */
static void
-selection_changed_cb (GnomeCalendar *gcal, gpointer data)
+gcal_calendar_selection_changed_cb (GnomeCalendar *gcal, gpointer data)
{
BonoboControl *control;
control = BONOBO_CONTROL (data);
- sensitize_commands (gcal, control);
+ sensitize_calendar_commands (gcal, control, TRUE);
}
+/* Callback used when the selection in the taskpad changes */
+static void
+gcal_taskpad_selection_changed_cb (GnomeCalendar *gcal, gpointer data)
+{
+ BonoboControl *control;
+
+ control = BONOBO_CONTROL (data);
+
+ sensitize_taskpad_commands (gcal, control, TRUE);
+}
+
+/* Callback used when the focus changes for a calendar view */
+static void
+gcal_calendar_focus_change_cb (GnomeCalendar *gcal, gboolean in, gpointer data)
+{
+ BonoboControl *control;
+ FocusData *focus;
+
+ control = BONOBO_CONTROL (data);
+
+ focus = gtk_object_get_data (GTK_OBJECT (control), "focus_data");
+ g_assert (focus != NULL);
+
+ if (in) {
+ gtk_signal_connect (GTK_OBJECT (gcal), "calendar_selection_changed",
+ GTK_SIGNAL_FUNC (gcal_calendar_selection_changed_cb), control);
+ sensitize_calendar_commands (gcal, control, TRUE);
+ focus->calendar_focused = TRUE;
+ } else if (focus->calendar_focused) {
+ gtk_signal_disconnect_by_func (GTK_OBJECT (gcal),
+ GTK_SIGNAL_FUNC (gcal_calendar_selection_changed_cb),
+ control);
+ sensitize_calendar_commands (gcal, control, FALSE);
+ focus->calendar_focused = FALSE;
+ }
+}
+
+/* Callback used when the taskpad focus changes */
+static void
+gcal_taskpad_focus_change_cb (GnomeCalendar *gcal, gboolean in, gpointer data)
+{
+ BonoboControl *control;
+ FocusData *focus;
+
+ control = BONOBO_CONTROL (data);
+
+ focus = gtk_object_get_data (GTK_OBJECT (control), "focus_data");
+ g_assert (focus != NULL);
+
+ if (in) {
+ gtk_signal_connect (GTK_OBJECT (gcal), "taskpad_selection_changed",
+ GTK_SIGNAL_FUNC (gcal_taskpad_selection_changed_cb), control);
+ sensitize_taskpad_commands (gcal, control, TRUE);
+ focus->taskpad_focused = TRUE;
+ } else if (focus->taskpad_focused) {
+ /* With Bonobo controls, we may get unpaired focus_out events.
+ * That is why we have to keep track of this ourselves instead
+ * of blindly assumming that we are getting this event because
+ * the taskpad was in fact focused.
+ */
+ gtk_signal_disconnect_by_func (GTK_OBJECT (gcal),
+ GTK_SIGNAL_FUNC (gcal_taskpad_selection_changed_cb),
+ control);
+ sensitize_taskpad_commands (gcal, control, FALSE);
+ focus->taskpad_focused = FALSE;
+ }
+
+}
+
+
static BonoboUIVerb verbs [] = {
BONOBO_UI_VERB ("CalendarPrint", file_print_cb),
BONOBO_UI_VERB ("CalendarPrintPreview", file_print_preview_cb),
@@ -550,10 +662,10 @@ static BonoboUIVerb verbs [] = {
BONOBO_UI_VERB ("CalendarSettings", settings_cmd),
- BONOBO_UI_VERB ("CutEvent", cut_event_cmd),
- BONOBO_UI_VERB ("CopyEvent", copy_event_cmd),
- BONOBO_UI_VERB ("PasteEvent", paste_event_cmd),
- BONOBO_UI_VERB ("DeleteEvent", delete_event_cmd),
+ BONOBO_UI_VERB ("Cut", cut_cmd),
+ BONOBO_UI_VERB ("Copy", copy_cmd),
+ BONOBO_UI_VERB ("Paste", paste_cmd),
+ BONOBO_UI_VERB ("Delete", delete_cmd),
BONOBO_UI_VERB ("CalendarPrev", previous_clicked),
BONOBO_UI_VERB ("CalendarToday", today_clicked),
@@ -574,10 +686,10 @@ static EPixmap pixmaps [] =
{
E_PIXMAP ("/menu/File/New/NewFirstItem/NewAppointment", "new_appointment.xpm"),
E_PIXMAP ("/menu/File/New/NewFirstItem/NewTask", "new_task-16.png"),
- E_PIXMAP ("/menu/EditPlaceholder/Edit/CutEvent", "16_cut.png"),
- E_PIXMAP ("/menu/EditPlaceholder/Edit/CopyEvent", "16_copy.png"),
- E_PIXMAP ("/menu/EditPlaceholder/Edit/PasteEvent", "16_paste.png"),
- E_PIXMAP ("/menu/EditPlaceholder/Edit/DeleteEvent", "evolution-trash-mini.png"),
+ E_PIXMAP ("/menu/EditPlaceholder/Edit/Cut", "16_cut.png"),
+ E_PIXMAP ("/menu/EditPlaceholder/Edit/Copy", "16_copy.png"),
+ E_PIXMAP ("/menu/EditPlaceholder/Edit/Paste", "16_paste.png"),
+ E_PIXMAP ("/menu/EditPlaceholder/Edit/Delete", "evolution-trash-mini.png"),
E_PIXMAP ("/menu/File/Print/Print", "print.xpm"),
E_PIXMAP ("/menu/File/Print/PrintPreview", "print-preview.xpm"),
E_PIXMAP ("/menu/ComponentActionsPlaceholder/Actions/NewAppointment", "new_appointment.xpm"),
@@ -607,6 +719,7 @@ calendar_control_activate (BonoboControl *control,
{
Bonobo_UIContainer remote_uih;
BonoboUIComponent *uic;
+ FocusData *focus;
uic = bonobo_control_get_ui_component (control);
g_assert (uic != NULL);
@@ -627,10 +740,13 @@ calendar_control_activate (BonoboControl *control,
gnome_calendar_setup_view_menus (gcal, uic);
- gtk_signal_connect (GTK_OBJECT (gcal), "selection_changed",
- GTK_SIGNAL_FUNC (selection_changed_cb), control);
+ gtk_signal_connect (GTK_OBJECT (gcal), "calendar_focus_change",
+ GTK_SIGNAL_FUNC (gcal_calendar_focus_change_cb), control);
+ gtk_signal_connect (GTK_OBJECT (gcal), "taskpad_focus_change",
+ GTK_SIGNAL_FUNC (gcal_taskpad_focus_change_cb), control);
- sensitize_commands (gcal, control);
+ sensitize_calendar_commands (gcal, control, FALSE);
+ sensitize_taskpad_commands (gcal, control, FALSE);
bonobo_ui_component_thaw (uic, NULL);
@@ -642,17 +758,30 @@ calendar_control_activate (BonoboControl *control,
#endif
calendar_set_folder_bar_label (gcal, control);
+
+ focus = g_new (FocusData, 1);
+ focus->calendar_focused = FALSE;
+ focus->taskpad_focused = FALSE;
+
+ gtk_object_set_data (GTK_OBJECT (control), "focus_data", focus);
}
void
calendar_control_deactivate (BonoboControl *control, GnomeCalendar *gcal)
{
+ FocusData *focus;
+
BonoboUIComponent *uic = bonobo_control_get_ui_component (control);
g_assert (uic != NULL);
+ focus = gtk_object_get_data (GTK_OBJECT (control), "focus_data");
+ g_assert (focus != NULL);
+
+ gtk_object_remove_data (GTK_OBJECT (control), "focus_data");
+ g_free (focus);
+
gnome_calendar_discard_view_menus (gcal);
- /* Stop monitoring the "selection_changed" signal */
gtk_signal_disconnect_by_data (GTK_OBJECT (gcal), control);
bonobo_ui_component_rm (uic, "/", NULL);
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index 57547febb7..73729e7cbf 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -5102,10 +5102,10 @@ e_day_view_key_press (GtkWidget *widget, GdkEventKey *event)
character. */
if (keyval == GDK_Return) {
initial_text = NULL;
- } else if ((keyval < 0x20)
- || (keyval > 0xFF)
+ } else if (((keyval >= 0x20) && (keyval <= 0xFF)
+ && (event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK)))
|| (event->length == 0)
- || (event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK))) {
+ || (keyval == GDK_Tab)) {
return FALSE;
} else
initial_text = e_utf8_from_gtk_event_key (widget, event->keyval, event->string);
diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c
index 3af297d2ad..4ab60ffc78 100644
--- a/calendar/gui/e-week-view.c
+++ b/calendar/gui/e-week-view.c
@@ -3293,10 +3293,10 @@ e_week_view_key_press (GtkWidget *widget, GdkEventKey *event)
character. */
if (event->keyval == GDK_Return) {
initial_text = NULL;
- } else if ((event->keyval < 0x20)
- || (event->keyval > 0xFF)
+ } else if (((event->keyval >= 0x20) && (event->keyval <= 0xFF)
+ && (event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK)))
|| (event->length == 0)
- || (event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK))) {
+ || (event->keyval == GDK_Tab)) {
return FALSE;
} else
initial_text = e_utf8_from_gtk_event_key (widget, event->keyval, event->string);
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index b0a044b239..1912068208 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -152,10 +152,20 @@ struct _GnomeCalendarPrivate {
enum {
DATES_SHOWN_CHANGED,
- SELECTION_CHANGED,
+ CALENDAR_SELECTION_CHANGED,
+ TASKPAD_SELECTION_CHANGED,
+ CALENDAR_FOCUS_CHANGE,
+ TASKPAD_FOCUS_CHANGE,
LAST_SIGNAL
};
+/* Used to indicate who has the focus within the calendar view */
+typedef enum {
+ FOCUS_CALENDAR,
+ FOCUS_TASKPAD,
+ FOCUS_OTHER
+} FocusLocation;
+
static guint gnome_calendar_signals[LAST_SIGNAL];
@@ -232,15 +242,40 @@ gnome_calendar_class_init (GnomeCalendarClass *class)
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
- gnome_calendar_signals[SELECTION_CHANGED] =
- gtk_signal_new ("selection_changed",
+ gnome_calendar_signals[CALENDAR_SELECTION_CHANGED] =
+ gtk_signal_new ("calendar_selection_changed",
GTK_RUN_LAST,
object_class->type,
- GTK_SIGNAL_OFFSET (GnomeCalendarClass,
- selection_changed),
+ GTK_SIGNAL_OFFSET (GnomeCalendarClass, calendar_selection_changed),
+ gtk_marshal_NONE__NONE,
+ GTK_TYPE_NONE, 0);
+
+ gnome_calendar_signals[TASKPAD_SELECTION_CHANGED] =
+ gtk_signal_new ("taskpad_selection_changed",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (GnomeCalendarClass, taskpad_selection_changed),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
+ gnome_calendar_signals[CALENDAR_FOCUS_CHANGE] =
+ gtk_signal_new ("calendar_focus_change",
+ GTK_RUN_FIRST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (GnomeCalendarClass, calendar_focus_change),
+ gtk_marshal_NONE__BOOL,
+ GTK_TYPE_NONE, 1,
+ GTK_TYPE_BOOL);
+
+ gnome_calendar_signals[TASKPAD_FOCUS_CHANGE] =
+ gtk_signal_new ("taskpad_focus_change",
+ GTK_RUN_FIRST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (GnomeCalendarClass, taskpad_focus_change),
+ gtk_marshal_NONE__BOOL,
+ GTK_TYPE_NONE, 1,
+ GTK_TYPE_BOOL);
+
gtk_object_class_add_signals (object_class,
gnome_calendar_signals,
LAST_SIGNAL);
@@ -248,7 +283,10 @@ gnome_calendar_class_init (GnomeCalendarClass *class)
object_class->destroy = gnome_calendar_destroy;
class->dates_shown_changed = NULL;
- class->selection_changed = NULL;
+ class->calendar_selection_changed = NULL;
+ class->taskpad_selection_changed = NULL;
+ class->calendar_focus_change = NULL;
+ class->taskpad_focus_change = NULL;
}
/* Callback used when the calendar query reports of an updated object */
@@ -359,6 +397,55 @@ gnome_calendar_get_current_view_widget (GnomeCalendar *gcal)
return retval;
}
+/* Gets the focus location based on who is the focused widget within the
+ * calendar view.
+ */
+static FocusLocation
+get_focus_location (GnomeCalendar *gcal)
+{
+ GnomeCalendarPrivate *priv;
+ ETable *etable;
+
+ priv = gcal->priv;
+
+ etable = e_calendar_table_get_table (E_CALENDAR_TABLE (priv->todo));
+
+ if (GTK_WIDGET_HAS_FOCUS (etable->table_canvas))
+ return FOCUS_TASKPAD;
+ else {
+ GtkWidget *widget;
+ EDayView *dv;
+ EWeekView *wv;
+
+ widget = gnome_calendar_get_current_view_widget (gcal);
+
+ switch (priv->current_view_type) {
+ case GNOME_CAL_DAY_VIEW:
+ case GNOME_CAL_WORK_WEEK_VIEW:
+ dv = E_DAY_VIEW (widget);
+
+ if (GTK_WIDGET_HAS_FOCUS (dv->top_canvas)
+ || GTK_WIDGET_HAS_FOCUS (dv->main_canvas))
+ return FOCUS_CALENDAR;
+ else
+ return FOCUS_OTHER;
+
+ case GNOME_CAL_WEEK_VIEW:
+ case GNOME_CAL_MONTH_VIEW:
+ wv = E_WEEK_VIEW (widget);
+
+ if (GTK_WIDGET_HAS_FOCUS (wv->main_canvas))
+ return FOCUS_CALENDAR;
+ else
+ return FOCUS_OTHER;
+
+ default:
+ g_assert_not_reached ();
+ return FOCUS_OTHER;
+ }
+ }
+}
+
/* Computes the range of time that the date navigator is showing */
static void
get_date_navigator_range (GnomeCalendar *gcal, time_t *start_time, time_t *end_time)
@@ -590,10 +677,79 @@ static void
view_selection_changed_cb (GtkWidget *view, GnomeCalendar *gcal)
{
gtk_signal_emit (GTK_OBJECT (gcal),
- gnome_calendar_signals[SELECTION_CHANGED]);
+ gnome_calendar_signals[CALENDAR_SELECTION_CHANGED]);
}
+/* Callback used when the taskpad receives a focus event. We emit the
+ * corresponding signal so that parents can change the menus as appropriate.
+ */
+static gint
+table_canvas_focus_change_cb (GtkWidget *widget, GdkEventFocus *event, gpointer data)
+{
+ GnomeCalendar *gcal;
+
+ gcal = GNOME_CALENDAR (data);
+
+ gtk_signal_emit (GTK_OBJECT (gcal), gnome_calendar_signals [TASKPAD_FOCUS_CHANGE],
+ event->in ? TRUE : FALSE);
+
+ return FALSE;
+}
+
+static gint
+calendar_focus_change_cb (GtkWidget *widget, GdkEventFocus *event, gpointer data)
+{
+ GnomeCalendar *gcal;
+
+ gcal = GNOME_CALENDAR (data);
+
+ gtk_signal_emit (GTK_OBJECT (gcal), gnome_calendar_signals [CALENDAR_FOCUS_CHANGE],
+ event->in ? TRUE : FALSE);
+
+ return FALSE;
+}
+
+/* Connects to the focus change signals of a day view widget */
+static void
+connect_day_view_focus (GnomeCalendar *gcal, EDayView *dv)
+{
+ gtk_signal_connect (GTK_OBJECT (dv->top_canvas), "focus_in_event",
+ GTK_SIGNAL_FUNC (calendar_focus_change_cb), gcal);
+ gtk_signal_connect (GTK_OBJECT (dv->top_canvas), "focus_out_event",
+ GTK_SIGNAL_FUNC (calendar_focus_change_cb), gcal);
+
+ gtk_signal_connect (GTK_OBJECT (dv->main_canvas), "focus_in_event",
+ GTK_SIGNAL_FUNC (calendar_focus_change_cb), gcal);
+ gtk_signal_connect (GTK_OBJECT (dv->main_canvas), "focus_out_event",
+ GTK_SIGNAL_FUNC (calendar_focus_change_cb), gcal);
+}
+
+/* Connects to the focus change signals of a week view widget */
+static void
+connect_week_view_focus (GnomeCalendar *gcal, EWeekView *wv)
+{
+ gtk_signal_connect (GTK_OBJECT (wv->main_canvas), "focus_in_event",
+ GTK_SIGNAL_FUNC (calendar_focus_change_cb), gcal);
+ gtk_signal_connect (GTK_OBJECT (wv->main_canvas), "focus_out_event",
+ GTK_SIGNAL_FUNC (calendar_focus_change_cb), gcal);
+}
+
+/* Callback used when the selection in the taskpad table changes. We just proxy
+ * the signal with our own one.
+ */
+static void
+table_selection_change_cb (ETable *etable, gpointer data)
+{
+ GnomeCalendar *gcal;
+ int n_selected;
+
+ gcal = GNOME_CALENDAR (data);
+
+ n_selected = e_table_selected_count (etable);
+ gtk_signal_emit (GTK_OBJECT (gcal), gnome_calendar_signals[TASKPAD_SELECTION_CHANGED]);
+}
+
static void
setup_widgets (GnomeCalendar *gcal)
{
@@ -601,6 +757,7 @@ setup_widgets (GnomeCalendar *gcal)
GtkWidget *w;
gchar *filename;
CalendarModel *model;
+ ETable *etable;
priv = gcal->priv;
@@ -671,6 +828,15 @@ setup_widgets (GnomeCalendar *gcal)
e_calendar_table_load_state (E_CALENDAR_TABLE (priv->todo), filename);
g_free (filename);
+ etable = e_calendar_table_get_table (E_CALENDAR_TABLE (priv->todo));
+ gtk_signal_connect (GTK_OBJECT (etable->table_canvas), "focus_in_event",
+ GTK_SIGNAL_FUNC (table_canvas_focus_change_cb), gcal);
+ gtk_signal_connect (GTK_OBJECT (etable->table_canvas), "focus_out_event",
+ GTK_SIGNAL_FUNC (table_canvas_focus_change_cb), gcal);
+
+ gtk_signal_connect (GTK_OBJECT (etable), "selection_change",
+ GTK_SIGNAL_FUNC (table_selection_change_cb), gcal);
+
/* The Day View. */
priv->day_view = e_day_view_new ();
e_day_view_set_calendar (E_DAY_VIEW (priv->day_view), gcal);
@@ -680,6 +846,8 @@ setup_widgets (GnomeCalendar *gcal)
gtk_signal_connect (GTK_OBJECT (priv->day_view), "selection_changed",
GTK_SIGNAL_FUNC (view_selection_changed_cb), gcal);
+ connect_day_view_focus (gcal, E_DAY_VIEW (priv->day_view));
+
/* The Work Week View. */
priv->work_week_view = e_day_view_new ();
e_day_view_set_work_week_view (E_DAY_VIEW (priv->work_week_view),
@@ -692,6 +860,8 @@ setup_widgets (GnomeCalendar *gcal)
gtk_signal_connect (GTK_OBJECT (priv->work_week_view), "selection_changed",
GTK_SIGNAL_FUNC (view_selection_changed_cb), gcal);
+ connect_day_view_focus (gcal, E_DAY_VIEW (priv->work_week_view));
+
/* The Week View. */
priv->week_view = e_week_view_new ();
e_week_view_set_calendar (E_WEEK_VIEW (priv->week_view), gcal);
@@ -701,6 +871,8 @@ setup_widgets (GnomeCalendar *gcal)
gtk_signal_connect (GTK_OBJECT (priv->week_view), "selection_changed",
GTK_SIGNAL_FUNC (view_selection_changed_cb), gcal);
+ connect_week_view_focus (gcal, E_WEEK_VIEW (priv->week_view));
+
/* The Month View. */
priv->month_view = e_week_view_new ();
e_week_view_set_calendar (E_WEEK_VIEW (priv->month_view), gcal);
@@ -711,6 +883,8 @@ setup_widgets (GnomeCalendar *gcal)
gtk_signal_connect (GTK_OBJECT (priv->month_view), "selection_changed",
GTK_SIGNAL_FUNC (view_selection_changed_cb), gcal);
+ connect_week_view_focus (gcal, E_WEEK_VIEW (priv->month_view));
+
gnome_calendar_update_config_settings (gcal, TRUE);
}
@@ -2453,73 +2627,97 @@ void
gnome_calendar_cut_clipboard (GnomeCalendar *gcal)
{
GnomeCalendarPrivate *priv;
+ FocusLocation location;
priv = gcal->priv;
- switch (priv->current_view_type) {
- case GNOME_CAL_DAY_VIEW :
- e_day_view_cut_clipboard (E_DAY_VIEW (priv->day_view));
- break;
- case GNOME_CAL_WORK_WEEK_VIEW :
- e_day_view_cut_clipboard (E_DAY_VIEW (priv->work_week_view));
- break;
- case GNOME_CAL_WEEK_VIEW :
- e_week_view_cut_clipboard (E_WEEK_VIEW (priv->week_view));
- break;
- case GNOME_CAL_MONTH_VIEW :
- e_week_view_cut_clipboard (E_WEEK_VIEW (priv->month_view));
- break;
- default:
+ location = get_focus_location (gcal);
+
+ if (location == FOCUS_CALENDAR) {
+ switch (priv->current_view_type) {
+ case GNOME_CAL_DAY_VIEW :
+ e_day_view_cut_clipboard (E_DAY_VIEW (priv->day_view));
+ break;
+ case GNOME_CAL_WORK_WEEK_VIEW :
+ e_day_view_cut_clipboard (E_DAY_VIEW (priv->work_week_view));
+ break;
+ case GNOME_CAL_WEEK_VIEW :
+ e_week_view_cut_clipboard (E_WEEK_VIEW (priv->week_view));
+ break;
+ case GNOME_CAL_MONTH_VIEW :
+ e_week_view_cut_clipboard (E_WEEK_VIEW (priv->month_view));
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+ } else if (location == FOCUS_TASKPAD)
+ e_calendar_table_cut_clipboard (E_CALENDAR_TABLE (priv->todo));
+ else
g_assert_not_reached ();
- }
}
void
gnome_calendar_copy_clipboard (GnomeCalendar *gcal)
{
GnomeCalendarPrivate *priv;
+ FocusLocation location;
priv = gcal->priv;
- switch (priv->current_view_type) {
- case GNOME_CAL_DAY_VIEW :
- e_day_view_copy_clipboard (E_DAY_VIEW (priv->day_view));
- break;
- case GNOME_CAL_WORK_WEEK_VIEW :
- e_day_view_copy_clipboard (E_DAY_VIEW (priv->work_week_view));
- break;
- case GNOME_CAL_WEEK_VIEW :
- e_week_view_copy_clipboard (E_WEEK_VIEW (priv->week_view));
- break;
- case GNOME_CAL_MONTH_VIEW :
- e_week_view_copy_clipboard (E_WEEK_VIEW (priv->month_view));
- break;
- default:
+ location = get_focus_location (gcal);
+
+ if (location == FOCUS_CALENDAR) {
+ switch (priv->current_view_type) {
+ case GNOME_CAL_DAY_VIEW :
+ e_day_view_copy_clipboard (E_DAY_VIEW (priv->day_view));
+ break;
+ case GNOME_CAL_WORK_WEEK_VIEW :
+ e_day_view_copy_clipboard (E_DAY_VIEW (priv->work_week_view));
+ break;
+ case GNOME_CAL_WEEK_VIEW :
+ e_week_view_copy_clipboard (E_WEEK_VIEW (priv->week_view));
+ break;
+ case GNOME_CAL_MONTH_VIEW :
+ e_week_view_copy_clipboard (E_WEEK_VIEW (priv->month_view));
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+ } else if (location == FOCUS_TASKPAD)
+ e_calendar_table_copy_clipboard (E_CALENDAR_TABLE (priv->todo));
+ else
g_assert_not_reached ();
- }
}
void
gnome_calendar_paste_clipboard (GnomeCalendar *gcal)
{
GnomeCalendarPrivate *priv;
+ FocusLocation location;
priv = gcal->priv;
- switch (priv->current_view_type) {
- case GNOME_CAL_DAY_VIEW :
- e_day_view_paste_clipboard (E_DAY_VIEW (priv->day_view));
- break;
- case GNOME_CAL_WORK_WEEK_VIEW :
- e_day_view_paste_clipboard (E_DAY_VIEW (priv->work_week_view));
- break;
- case GNOME_CAL_WEEK_VIEW :
- e_week_view_paste_clipboard (E_WEEK_VIEW (priv->week_view));
- break;
- case GNOME_CAL_MONTH_VIEW :
- e_week_view_paste_clipboard (E_WEEK_VIEW (priv->month_view));
- break;
- }
+ location = get_focus_location (gcal);
+
+ if (location == FOCUS_CALENDAR) {
+ switch (priv->current_view_type) {
+ case GNOME_CAL_DAY_VIEW :
+ e_day_view_paste_clipboard (E_DAY_VIEW (priv->day_view));
+ break;
+ case GNOME_CAL_WORK_WEEK_VIEW :
+ e_day_view_paste_clipboard (E_DAY_VIEW (priv->work_week_view));
+ break;
+ case GNOME_CAL_WEEK_VIEW :
+ e_week_view_paste_clipboard (E_WEEK_VIEW (priv->week_view));
+ break;
+ case GNOME_CAL_MONTH_VIEW :
+ e_week_view_paste_clipboard (E_WEEK_VIEW (priv->month_view));
+ break;
+ }
+ } else if (location == FOCUS_TASKPAD)
+ e_calendar_table_paste_clipboard (E_CALENDAR_TABLE (priv->todo));
+ else
+ g_assert_not_reached ();
}
@@ -2581,19 +2779,55 @@ gnome_calendar_get_num_events_selected (GnomeCalendar *gcal)
return retval;
}
+/**
+ * gnome_calendar_get_num_tasks_selected:
+ * @gcal: A calendar view.
+ *
+ * Queries the number of tasks that are currently selected in the task pad of a
+ * calendar view.
+ *
+ * Return value: Number of selected tasks.
+ **/
+gint
+gnome_calendar_get_num_tasks_selected (GnomeCalendar *gcal)
+{
+ GnomeCalendarPrivate *priv;
+ ETable *etable;
+
+ g_return_val_if_fail (gcal != NULL, -1);
+ g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), -1);
+
+ priv = gcal->priv;
+
+ etable = e_calendar_table_get_table (E_CALENDAR_TABLE (priv->todo));
+ return e_table_selected_count (etable);
+}
+
void
-gnome_calendar_delete_event (GnomeCalendar *gcal)
+gnome_calendar_delete_selection (GnomeCalendar *gcal)
{
+ GnomeCalendarPrivate *priv;
+ FocusLocation location;
GtkWidget *view;
g_return_if_fail (GNOME_IS_CALENDAR (gcal));
- view = gnome_calendar_get_current_view_widget (gcal);
- if (E_IS_DAY_VIEW (view))
- e_day_view_delete_event (E_DAY_VIEW (view));
+ priv = gcal->priv;
+
+ location = get_focus_location (gcal);
+
+ if (location == FOCUS_CALENDAR) {
+ view = gnome_calendar_get_current_view_widget (gcal);
+
+ if (E_IS_DAY_VIEW (view))
+ e_day_view_delete_event (E_DAY_VIEW (view));
+ else
+ e_week_view_delete_event (E_WEEK_VIEW (view));
+ } else if (location == FOCUS_TASKPAD)
+ e_calendar_table_delete_selected (E_CALENDAR_TABLE (priv->todo));
else
- e_week_view_delete_event (E_WEEK_VIEW (view));
+ g_assert_not_reached ();
}
diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h
index 620dbc3553..64273277ec 100644
--- a/calendar/gui/gnome-cal.h
+++ b/calendar/gui/gnome-cal.h
@@ -68,7 +68,12 @@ struct _GnomeCalendarClass {
/* Notification signals */
void (* dates_shown_changed) (GnomeCalendar *gcal);
- void (* selection_changed) (GnomeCalendar *gcal);
+
+ void (* calendar_selection_changed) (GnomeCalendar *gcal);
+ void (* taskpad_selection_changed) (GnomeCalendar *gcal);
+
+ void (* calendar_focus_change) (GnomeCalendar *gcal, gboolean in);
+ void (* taskpad_focus_change) (GnomeCalendar *gcal, gboolean in);
};
@@ -135,6 +140,9 @@ gboolean gnome_calendar_get_visible_time_range (GnomeCalendar *gcal,
/* Returns the number of selected events (0 or 1 at present). */
gint gnome_calendar_get_num_events_selected (GnomeCalendar *gcal);
+/* Returns the number of selected tasks */
+gint gnome_calendar_get_num_tasks_selected (GnomeCalendar *gcal);
+
/* Tells the calendar to reload all config settings. initializing should be
TRUE when we are setting the config settings for the first time. */
void gnome_calendar_update_config_settings (GnomeCalendar *gcal,
@@ -149,7 +157,7 @@ void gnome_calendar_cut_clipboard (GnomeCalendar *gcal);
void gnome_calendar_copy_clipboard (GnomeCalendar *gcal);
void gnome_calendar_paste_clipboard (GnomeCalendar *gcal);
-void gnome_calendar_delete_event (GnomeCalendar *gcal);
+void gnome_calendar_delete_selection (GnomeCalendar *gcal);