managesieve: add newly created scripts to manager window list
authorCharles Lehner <cel@celehner.com>
Fri, 17 Jul 2015 05:04:38 +0000 (01:04 -0400)
committerCharles Lehner <cel@celehner.com>
Fri, 17 Jul 2015 05:21:06 +0000 (01:21 -0400)
src/plugins/managesieve/sieve_editor.c
src/plugins/managesieve/sieve_editor.h
src/plugins/managesieve/sieve_manager.c
src/plugins/managesieve/sieve_manager.h

index dc89f7f..e085dcb 100644 (file)
@@ -41,6 +41,7 @@
 #include "mainwindow.h"
 #include "message_search.h"
 #include "managesieve.h"
+#include "sieve_manager.h"
 #include "sieve_editor.h"
 
 GSList *editors = NULL;
@@ -348,6 +349,13 @@ static void got_data_saved(SieveSession *session, gboolean abort,
                if (result->code == SIEVE_CODE_NONE) {
                        result->description = _("Script saved successfully.");
                }
+
+               if (page->is_new) {
+                       /* notify manager windows of newly created script */
+                       page->is_new = FALSE;
+                       sieve_manager_script_created(session,
+                                       page->script_name);
+               }
        }
        sieve_editor_update_status(page, result);
 }
index bac8eea..60d3d86 100644 (file)
@@ -38,6 +38,7 @@ struct SieveEditorPage
        gboolean        first_line;
        gboolean        modified;
        gboolean        closing;
+       gboolean        is_new;
 
        /* callback for failure to load the script */
        sieve_session_cb_fn on_load_error;
index 65e6dbf..8a786e0 100644 (file)
@@ -163,6 +163,7 @@ static void filter_add(GtkWidget *widget, SieveManagerPage *page)
                        (sieve_session_cb_fn)filter_got_load_error, page);
        } else {
                editor = sieve_editor_new(session, filter_name);
+               editor->is_new = TRUE;
                sieve_editor_show(editor);
        }
 }
@@ -808,3 +809,14 @@ void sieve_manager_show()
        manager_pages = g_slist_prepend(manager_pages, page);
        gtk_widget_show_all(page->window);
 }
+
+void sieve_manager_script_created(SieveSession *session, const gchar *name)
+{
+       SieveManagerPage *page;
+       SieveScript script = {.name = (gchar *)name};
+       GSList *cur;
+
+       manager_sessions_foreach(cur, session, page) {
+               filters_list_insert_filter(page, &script);
+       }
+}
index 9665bb8..58f08f0 100644 (file)
@@ -38,5 +38,7 @@ struct SieveManagerPage
 
 void sieve_manager_show(void);
 void sieve_manager_done(SieveManagerPage *page);
+void sieve_manager_script_created(SieveSession *session,
+               const gchar *filter_name);
 
 #endif /* SIEVE_MANAGER_H */