diff options
author | Federico Mena Quintero <federico@ximian.com> | 2001-10-31 19:17:04 +0800 |
---|---|---|
committer | Federico Mena Quintero <federico@src.gnome.org> | 2001-10-31 19:17:04 +0800 |
commit | 1a54303e49a9f870f48031ffe54fcf480ac56d6f (patch) | |
tree | 0dc700a2b082f570c9f803430222c516232cff82 /calendar/gui/calendar-commands.c | |
parent | dccfbb1fbf368a8edb2ab78fd07b69b767ec1997 (diff) | |
download | gsoc2013-evolution-1a54303e49a9f870f48031ffe54fcf480ac56d6f.tar.gz gsoc2013-evolution-1a54303e49a9f870f48031ffe54fcf480ac56d6f.tar.zst gsoc2013-evolution-1a54303e49a9f870f48031ffe54fcf480ac56d6f.zip |
Fix bug #13723.
2001-10-31 Federico Mena Quintero <federico@ximian.com>
Fix bug #13723.
* gui/gnome-cal.h (GnomeCalendarClass): New signals
"calendar_focus_change", "taskpad_focus_change", and
"taskpad_selection_changed". Renamed "selection_changed" to
"calendar_selection_changed".
* gui/gnome-cal.c (gnome_calendar_get_num_tasks_selected): New
function.
(setup_widgets): Connect to the focus event signals of the task
pad and the calendar view widgets.
(gnome_calendar_delete_selection): Renamed from
gnome_calendar_delete_event().
(gnome_calendar_cut_clipboard): Handle the current focus location.
(gnome_calendar_copy_clipboard): Likewise.
(gnome_calendar_paste_clipboard): Likewise.
(gnome_calendar_delete_selection): Likewise.
(table_selection_change_cb): New callback.
* gui/calendar-commands.c (sensitize_calendar_commands): Take in
whether we should unconditionally disable everything.
(sensitize_taskpad_commands): Analogous function to the above.
(gcal_calendar_focus_change_cb): New callback, used for calendar
views.
(gcal_taskpad_focus_change_cb): New callback, used for the
taskpad.
* gui/e-day-view.c (e_day_view_key_press): Use a better test for
keys that should start editing. Fixes bug #6447.
* gui/e-week-view.c (e_week_view_key_press): Likewise.
svn path=/trunk/; revision=14528
Diffstat (limited to 'calendar/gui/calendar-commands.c')
-rw-r--r-- | calendar/gui/calendar-commands.c | 181 |
1 files changed, 155 insertions, 26 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); |