[anjuta] document-manager: Emit "document-[added|removed]" signals.



commit 91dedbfac317e6e5e9ff9d8861ba5df250e8d198
Author: Carl-Anton Ingmarsson <ca ingmarsson gmail com>
Date:   Sun Jan 6 11:12:53 2013 +0100

    document-manager: Emit "document-[added|removed]" signals.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=691222

 plugins/document-manager/anjuta-docman.c |   16 ++++++++++++++++
 plugins/document-manager/anjuta-docman.h |    1 +
 plugins/document-manager/plugin.c        |   13 +++++++++++++
 3 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/plugins/document-manager/anjuta-docman.c b/plugins/document-manager/anjuta-docman.c
index cc262e1..84ad0e4 100644
--- a/plugins/document-manager/anjuta-docman.c
+++ b/plugins/document-manager/anjuta-docman.c
@@ -46,6 +46,7 @@ enum
 {
 	DOC_ADDED,
 	DOC_CHANGED,
+	DOC_REMOVED,
 	LAST_SIGNAL
 };
 
@@ -1158,6 +1159,16 @@ anjuta_docman_class_init (AnjutaDocmanClass *klass)
 			G_TYPE_NONE,
 			1,
 			G_TYPE_OBJECT);
+	docman_signals [DOC_REMOVED] =
+		g_signal_new ("document-removed",
+			ANJUTA_TYPE_DOCMAN,
+			G_SIGNAL_RUN_LAST,
+			G_STRUCT_OFFSET (AnjutaDocmanClass, document_removed),
+			NULL, NULL,
+			g_cclosure_marshal_VOID__OBJECT,
+			G_TYPE_NONE,
+			1,
+			G_TYPE_OBJECT);
 
 	}
 }
@@ -1357,6 +1368,11 @@ anjuta_docman_remove_document (AnjutaDocman *docman, IAnjutaDocument *doc)
 
 		g_free (page);
 	}
+
+	/* Emit document-removed */
+	g_signal_emit(docman, docman_signals[DOC_REMOVED], 0, doc);
+	
+
 	gtk_widget_destroy(GTK_WIDGET(doc));
 	anjuta_docman_update_documents_menu(docman);
 
diff --git a/plugins/document-manager/anjuta-docman.h b/plugins/document-manager/anjuta-docman.h
index 2e4f8a1..cf21c74 100644
--- a/plugins/document-manager/anjuta-docman.h
+++ b/plugins/document-manager/anjuta-docman.h
@@ -53,6 +53,7 @@ struct _AnjutaDocmanClass {
 	/* Signals */
 	void (*document_added) (IAnjutaDocument *document);
 	void (*document_changed) (IAnjutaDocument *new_document);
+	void (*document_removed) (IAnjutaDocument *document);
 };
 
 GType anjuta_docman_get_type (void);
diff --git a/plugins/document-manager/plugin.c b/plugins/document-manager/plugin.c
index 4d9dbb2..76ac95e 100644
--- a/plugins/document-manager/plugin.c
+++ b/plugins/document-manager/plugin.c
@@ -1277,6 +1277,14 @@ docman_plugin_set_tab_pos (DocmanPlugin *ep)
 }
 
 static void
+on_document_removed (AnjutaDocman *docman, IAnjutaDocument *doc,
+					 AnjutaPlugin *plugin)
+{
+	/* Emit document-removed signal */
+	g_signal_emit_by_name (plugin, "document-removed", doc);
+}
+
+static void
 on_document_added (AnjutaDocman *docman, IAnjutaDocument *doc,
 				   AnjutaPlugin *plugin)
 {
@@ -1319,6 +1327,9 @@ on_document_added (AnjutaDocman *docman, IAnjutaDocument *doc,
 									   highlight_submenu);
 		}
 	}
+
+	/* Emit document-added signal */
+	g_signal_emit_by_name (docman_plugin, "document-added", doc);
 }
 
 static gboolean
@@ -1617,6 +1628,8 @@ activate_plugin (AnjutaPlugin *plugin)
 	ANJUTA_DOCMAN(docman)->shell = anjuta_plugin_get_shell(plugin);
 	g_signal_connect (G_OBJECT (docman), "document-added",
 					  G_CALLBACK (on_document_added), plugin);
+	g_signal_connect (G_OBJECT (docman), "document-removed",
+					  G_CALLBACK (on_document_removed), plugin);
 	g_signal_connect (G_OBJECT (docman), "document-changed",
 					  G_CALLBACK (on_document_changed), plugin);
 	g_signal_connect (G_OBJECT (plugin->shell), "key-press-event",



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]