diff options
author | Damon Chaplin <damon@helixcode.com> | 2000-12-11 10:22:06 +0800 |
---|---|---|
committer | Damon Chaplin <damon@src.gnome.org> | 2000-12-11 10:22:06 +0800 |
commit | ba28f6622636fc3932aab4a0551e2d86b69fd6e4 (patch) | |
tree | 4fa39103cd28af9eff5a79778eb22fe2c9b8a9bf /calendar/gui/dialogs | |
parent | 50fcc2ad7d4c717aafa62195988a8362fc7a3f19 (diff) | |
download | gsoc2013-evolution-ba28f6622636fc3932aab4a0551e2d86b69fd6e4.tar.gz gsoc2013-evolution-ba28f6622636fc3932aab4a0551e2d86b69fd6e4.tar.zst gsoc2013-evolution-ba28f6622636fc3932aab4a0551e2d86b69fd6e4.zip |
added changed flags and added calls to a new function
2000-12-11 Damon Chaplin <damon@helixcode.com>
* gui/event-editor.c: added changed flags and added calls to a new
function event_editor_set_changed() to set & reset this flag.
Added prompt_to_save_changed() which is called when the user
selects File/Close or the window's close button.
Fixed the 'All day event' toggle button.
Made the 'Alarm' page sensitive as appropriate when filling widgets.
(Though note that the alarm widgets are not being set yet.)
* gui/dialogs/task-editor.c: added changed flag as above.
* gui/event-editor-dialog.glade: used good names for all the
classification radio buttons so we can access them in the code.
* gui/event-editor.c (init_widgets): use the "show week numbers" config
option in the recurrence preview calendar.
* gui/e-day-view.c (e_day_view_update_event_label): use 9:00 instead
of 09:00 in the main view, as we do everywhere else now. It means the
times won't line up, but they are easier to read which I think is
better.
Added support for Page Up/Down, though I think it should move the
selection rather than just scroll the canvas.
* cal-util/cal-recur.c (generate_instances_for_chunk): removed the
end parameter since we should be using the chunk end time now.
Added single_rule parameter for when we are generating the
occurrences of a single RRULE, in which case the event's start date is
not included in the occurrences output (unless it results from the
RRULE expansion). Both of these fix problems when using COUNT.
* gui/gnome-cal.c (gnome_calendar_on_date_navigator_selection_changed):
fixed bug when checking if the new start day starts on the week start
day. If you select a complete week it should now show the Week view.
svn path=/trunk/; revision=6896
Diffstat (limited to 'calendar/gui/dialogs')
-rw-r--r-- | calendar/gui/dialogs/task-editor.c | 140 |
1 files changed, 132 insertions, 8 deletions
diff --git a/calendar/gui/dialogs/task-editor.c b/calendar/gui/dialogs/task-editor.c index 8cd7c33ba9..211c31321a 100644 --- a/calendar/gui/dialogs/task-editor.c +++ b/calendar/gui/dialogs/task-editor.c @@ -81,6 +81,11 @@ typedef struct { GtkWidget *completed_date; GtkWidget *url; + + /* Call task_editor_set_changed() to set this to TRUE when any field + in the dialog is changed. When the user closes the dialog we will + prompt to save changes. */ + gboolean changed; } TaskEditorPrivate; @@ -165,7 +170,13 @@ static void status_changed (GtkMenu *menu, TaskEditor *tedit); static void percent_complete_changed (GtkAdjustment *adj, TaskEditor *tedit); +static void field_changed (GtkWidget *widget, + TaskEditor *tedit); +static void task_editor_set_changed (TaskEditor *tedit, + gboolean changed); +static gboolean prompt_to_save_changes (TaskEditor *tedit); +/* The function libglade calls to create the EDateEdit widgets in the GUI. */ GtkWidget * task_editor_create_date_edit (void); static GtkObjectClass *parent_class; @@ -196,6 +207,8 @@ task_editor_init (TaskEditor *tedit) tedit->priv = priv; priv->ignore_callbacks = FALSE; + + task_editor_set_changed (tedit, FALSE); } @@ -339,10 +352,12 @@ app_delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data) { TaskEditor *tedit; - /* FIXME: need to check for a dirty object */ + g_return_val_if_fail (IS_TASK_EDITOR (data), TRUE); tedit = TASK_EDITOR (data); - close_dialog (tedit); + + if (prompt_to_save_changes (tedit)) + close_dialog (tedit); return TRUE; } @@ -435,6 +450,30 @@ init_widgets (TaskEditor *tedit) gtk_signal_connect (GTK_OBJECT (GTK_SPIN_BUTTON (priv->percent_complete)->adjustment), "value_changed", GTK_SIGNAL_FUNC (percent_complete_changed), tedit); + + /* Connect the default signal handler to use to make sure the "changed" + field gets set whenever a field is changed. */ + gtk_signal_connect (GTK_OBJECT (priv->summary), "changed", + GTK_SIGNAL_FUNC (field_changed), tedit); + gtk_signal_connect (GTK_OBJECT (priv->due_date), "changed", + GTK_SIGNAL_FUNC (field_changed), tedit); + gtk_signal_connect (GTK_OBJECT (priv->start_date), "changed", + GTK_SIGNAL_FUNC (field_changed), tedit); + gtk_signal_connect (GTK_OBJECT (GTK_OPTION_MENU (priv->priority)->menu), + "deactivate", + GTK_SIGNAL_FUNC (field_changed), tedit); + gtk_signal_connect (GTK_OBJECT (GTK_OPTION_MENU (priv->classification)->menu), + "deactivate", + GTK_SIGNAL_FUNC (field_changed), tedit); + gtk_signal_connect (GTK_OBJECT (priv->description), "changed", + GTK_SIGNAL_FUNC (field_changed), tedit); + gtk_signal_connect (GTK_OBJECT (priv->contacts), "changed", + GTK_SIGNAL_FUNC (field_changed), tedit); + gtk_signal_connect (GTK_OBJECT (priv->categories), "changed", + GTK_SIGNAL_FUNC (field_changed), tedit); + gtk_signal_connect (GTK_OBJECT (priv->url), "changed", + GTK_SIGNAL_FUNC (field_changed), tedit); + } static void @@ -709,6 +748,8 @@ fill_widgets (TaskEditor *tedit) priv = tedit->priv; + task_editor_set_changed (tedit, FALSE); + clear_widgets (tedit); if (!priv->comp) @@ -785,7 +826,6 @@ fill_widgets (TaskEditor *tedit) status = ICAL_STATUS_NEEDSACTION; } } - g_print ("Setting status\n"); e_dialog_option_menu_set (priv->status, status, status_map); /* Priority. */ @@ -796,13 +836,11 @@ fill_widgets (TaskEditor *tedit) } else { priority = PRIORITY_UNDEFINED; } - g_print ("Setting priority\n"); e_dialog_option_menu_set (priv->priority, priority, priority_map); /* Classification. */ cal_component_get_classification (priv->comp, &classification); - g_print ("Setting classification\n"); e_dialog_option_menu_set (priv->classification, classification, classification_map); @@ -836,6 +874,8 @@ save_todo_object (TaskEditor *tedit) if (!cal_client_update_object (priv->client, priv->comp)) g_message ("save_todo_object(): Could not update the object!"); + else + task_editor_set_changed (tedit, FALSE); } @@ -956,6 +996,7 @@ dialog_to_comp_object (TaskEditor *tedit) if (url) g_free (url); + cal_component_commit_sequence (comp); } @@ -1021,11 +1062,12 @@ file_close_cb (GtkWidget *widget, gpointer data) { TaskEditor *tedit; - tedit = TASK_EDITOR (data); + g_return_if_fail (IS_TASK_EDITOR (data)); - g_return_if_fail (IS_TASK_EDITOR (tedit)); + tedit = TASK_EDITOR (data); - close_dialog (tedit); + if (prompt_to_save_changes (tedit)) + close_dialog (tedit); } @@ -1119,6 +1161,8 @@ completed_changed (EDateEdit *dedit, if (priv->ignore_callbacks) return; + task_editor_set_changed (tedit, TRUE); + priv->ignore_callbacks = TRUE; t = e_date_edit_get_time (E_DATE_EDIT (priv->completed_date)); if (t == -1) { @@ -1152,6 +1196,8 @@ status_changed (GtkMenu *menu, if (priv->ignore_callbacks) return; + task_editor_set_changed (tedit, TRUE); + status = e_dialog_option_menu_get (priv->status, status_map); priv->ignore_callbacks = TRUE; if (status == ICAL_STATUS_NEEDSACTION) { @@ -1182,6 +1228,8 @@ percent_complete_changed (GtkAdjustment *adj, if (priv->ignore_callbacks) return; + task_editor_set_changed (tedit, TRUE); + percent = e_dialog_spin_get_int (priv->percent_complete); priv->ignore_callbacks = TRUE; @@ -1205,3 +1253,79 @@ percent_complete_changed (GtkAdjustment *adj, priv->ignore_callbacks = FALSE; } + +/* This is called when all fields except those handled above (status, percent + complete & completed date) are changed. It just sets the "changed" flag. */ +static void +field_changed (GtkWidget *widget, + TaskEditor *tedit) +{ + TaskEditorPrivate *priv; + + g_return_if_fail (IS_TASK_EDITOR (tedit)); + + priv = tedit->priv; + + if (priv->ignore_callbacks) + return; + + task_editor_set_changed (tedit, TRUE); +} + + +static void +task_editor_set_changed (TaskEditor *tedit, + gboolean changed) +{ + TaskEditorPrivate *priv; + + priv = tedit->priv; + +#if 0 + g_print ("In task_editor_set_changed: %s\n", + changed ? "TRUE" : "FALSE"); +#endif + + priv->changed = changed; +} + + +/* This checks if the "changed" field is set, and if so it prompts to save + the changes using a "Save/Discard/Cancel" modal dialog. It then saves the + changes if requested. It returns TRUE if the dialog should now be closed. */ +static gboolean +prompt_to_save_changes (TaskEditor *tedit) +{ + TaskEditorPrivate *priv; + GtkWidget *dialog; + + priv = tedit->priv; + + if (!priv->changed) + return TRUE; + + dialog = gnome_message_box_new (_("Do you want to save changes?"), + GNOME_MESSAGE_BOX_QUESTION, + GNOME_STOCK_BUTTON_YES, + GNOME_STOCK_BUTTON_NO, + GNOME_STOCK_BUTTON_CANCEL, + NULL); + + gnome_dialog_set_parent (GNOME_DIALOG (dialog), + GTK_WINDOW (priv->app)); + + switch (gnome_dialog_run_and_close (GNOME_DIALOG (dialog))) { + case 0: /* Save */ + /* FIXME: If an error occurs here, we should popup a dialog + and then return FALSE. */ + save_todo_object (tedit); + return TRUE; + case 1: /* Discard */ + return TRUE; + case 2: /* Cancel */ + default: + return FALSE; + break; + } + +} |