From d2de841ec6dbae4ba9439bf3b30da8d4048ea4de Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Fri, 11 May 2012 12:38:38 +0200 Subject: Bug #559710 - Do not close Event/Task/Memo editor on save --- calendar/gui/dialogs/comp-editor.c | 62 +++++++++++++++++++++++++++++++++++--- 1 file changed, 58 insertions(+), 4 deletions(-) diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c index 033d80a4a7..b647960b2f 100644 --- a/calendar/gui/dialogs/comp-editor.c +++ b/calendar/gui/dialogs/comp-editor.c @@ -160,6 +160,7 @@ static const gchar *ui = " " " " " " +" " " " " " " " @@ -184,6 +185,7 @@ static const gchar *ui = " " " " " " +" \n" " \n" "#if !EXPRESS\n" " \n" @@ -918,8 +920,8 @@ remove_event_dialog (ECalClient *client, } static void -action_save_cb (GtkAction *action, - CompEditor *editor) +save_and_close_editor (CompEditor *editor, + gboolean can_close) { CompEditorPrivate *priv = editor->priv; EAttachmentStore *store; @@ -1028,8 +1030,26 @@ action_save_cb (GtkAction *action, } else correct = FALSE; - if (correct) - close_dialog (editor); + if (correct) { + if (can_close) + close_dialog (editor); + else + comp_editor_set_changed (editor, FALSE); + } +} + +static void +action_save_cb (GtkAction *action, + CompEditor *editor) +{ + save_and_close_editor (editor, FALSE); +} + +static void +action_save_and_close_cb (GtkAction *action, + CompEditor *editor) +{ + save_and_close_editor (editor, TRUE); } static void @@ -1181,6 +1201,13 @@ static GtkActionEntry core_entries[] = { N_("Save current changes"), G_CALLBACK (action_save_cb) }, + { "save-and-close", + NULL, + N_("Save and Close"), + NULL, + N_("Save current changes and close editor"), + G_CALLBACK (action_save_and_close_cb) }, + { "select-all", GTK_STOCK_SELECT_ALL, NULL, @@ -1988,6 +2015,33 @@ comp_editor_init (CompEditor *editor) priv->ui_manager, action_group, 0); g_object_unref (action_group); + action = gtk_action_group_get_action (action_group, "save-and-close"); + if (action) { + GtkAction *save_action; + GIcon *icon; + GIcon *emblemed_icon; + GEmblem *emblem; + + icon = g_themed_icon_new (GTK_STOCK_CLOSE); + emblemed_icon = g_themed_icon_new (GTK_STOCK_SAVE); + emblem = g_emblem_new (emblemed_icon); + g_object_unref (emblemed_icon); + + emblemed_icon = g_emblemed_icon_new (icon, emblem); + g_object_unref (emblem); + g_object_unref (icon); + + gtk_action_set_gicon (action, emblemed_icon); + + g_object_unref (emblemed_icon); + + save_action = gtk_action_group_get_action (action_group, "save"); + g_object_bind_property ( + save_action, "sensitive", + action, "sensitive", + G_BINDING_SYNC_CREATE); + } + action_group = gtk_action_group_new ("individual"); gtk_action_group_set_translation_domain ( action_group, GETTEXT_PACKAGE); -- cgit v1.2.3