Revision: 2936 http://geany.svn.sourceforge.net/geany/?rev=2936&view=rev Author: ntrel Date: 2008-09-11 15:03:58 +0000 (Thu, 11 Sep 2008)
Log Message: ----------- Add plugin signal "document-close", sent just before a document is closed.
Modified Paths: -------------- branches/split-window-plugin/ChangeLog branches/split-window-plugin/doc/plugins.dox branches/split-window-plugin/src/document.c branches/split-window-plugin/src/geanyobject.c branches/split-window-plugin/src/geanyobject.h
Modified: branches/split-window-plugin/ChangeLog =================================================================== --- branches/split-window-plugin/ChangeLog 2008-09-10 14:49:16 UTC (rev 2935) +++ branches/split-window-plugin/ChangeLog 2008-09-11 15:03:58 UTC (rev 2936) @@ -1,3 +1,11 @@ +2008-09-11 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com> + + * src/geanyobject.c, src/geanyobject.h, src/document.c, + doc/plugins.dox: + Add plugin signal "document-close", sent just before a document is + closed. + + 2008-09-10 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* plugins/splitwindow.c:
Modified: branches/split-window-plugin/doc/plugins.dox =================================================================== --- branches/split-window-plugin/doc/plugins.dox 2008-09-10 14:49:16 UTC (rev 2935) +++ branches/split-window-plugin/doc/plugins.dox 2008-09-11 15:03:58 UTC (rev 2936) @@ -121,6 +121,17 @@ * @param user_data user data. * @endsignaldef * + * @signaldef document-close + * @signalproto + * void user_function(GObject *obj, GeanyDocument *doc, gpointer user_data); + * @endsignalproto + * @signaldesc + * Sent before closing a document. + * @param obj a GeanyObject instance, should be ignored. + * @param doc the document about to be closed. + * @param user_data user data. + * @endsignaldef + * * @signaldef project-open * @signalproto * void user_function(GObject *obj, GKeyFile *config, gpointer user_data);
Modified: branches/split-window-plugin/src/document.c =================================================================== --- branches/split-window-plugin/src/document.c 2008-09-10 14:49:16 UTC (rev 2935) +++ branches/split-window-plugin/src/document.c 2008-09-11 15:03:58 UTC (rev 2936) @@ -472,53 +472,60 @@ gboolean document_remove_page(guint page_num) { GeanyDocument *doc = document_get_from_page(page_num); + Document *fdoc = DOCUMENT(doc);
- if (doc != NULL) + if (doc == NULL) { - Document *fdoc = DOCUMENT(doc); + geany_debug("Error: page_num: %d", page_num); + return FALSE; + } + + if (doc->changed && ! dialogs_show_unsaved_file(doc)) + { + return FALSE; + } + + /* tell any plugins that the document is about to be closed */ + if (geany_object) + { + g_signal_emit_by_name(geany_object, "document-close", doc); + }
- if (doc->changed && ! dialogs_show_unsaved_file(doc)) - { - return FALSE; - } - /* Checking real_path makes it likely the file exists on disk */ - if (! main_status.closing_all && doc->real_path != NULL) - ui_add_recent_file(doc->file_name); + /* Checking real_path makes it likely the file exists on disk */ + if (! main_status.closing_all && doc->real_path != NULL) + ui_add_recent_file(doc->file_name);
- notebook_remove_page(page_num); - treeviews_remove_document(doc); - navqueue_remove_file(doc->file_name); - msgwin_status_add(_("File %s closed."), DOC_FILENAME(doc)); - g_free(doc->encoding); - g_free(fdoc->saved_encoding.encoding); - g_free(doc->file_name); - g_free(doc->real_path); - tm_workspace_remove_object(doc->tm_file, TRUE, TRUE); + notebook_remove_page(page_num); + treeviews_remove_document(doc); + navqueue_remove_file(doc->file_name); + msgwin_status_add(_("File %s closed."), DOC_FILENAME(doc)); + g_free(doc->encoding); + g_free(fdoc->saved_encoding.encoding); + g_free(doc->file_name); + g_free(doc->real_path); + tm_workspace_remove_object(doc->tm_file, TRUE, TRUE);
- editor_destroy(doc->editor); - doc->editor = NULL; + editor_destroy(doc->editor); + doc->editor = NULL;
- doc->is_valid = FALSE; - doc->file_name = NULL; - doc->real_path = NULL; - doc->file_type = NULL; - doc->encoding = NULL; - doc->has_bom = FALSE; - doc->tm_file = NULL; - document_undo_clear(doc); - if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.notebook)) == 0) - { - treeviews_update_tag_list(NULL, FALSE); - /*on_notebook1_switch_page(GTK_NOTEBOOK(main_widgets.notebook), NULL, 0, NULL);*/ - ui_set_window_title(NULL); - ui_save_buttons_toggle(FALSE); - ui_document_buttons_update(); - build_menu_update(NULL); - } - return TRUE; + doc->is_valid = FALSE; + doc->file_name = NULL; + doc->real_path = NULL; + doc->file_type = NULL; + doc->encoding = NULL; + doc->has_bom = FALSE; + doc->tm_file = NULL; + document_undo_clear(doc); + if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.notebook)) == 0) + { + treeviews_update_tag_list(NULL, FALSE); + /*on_notebook1_switch_page(GTK_NOTEBOOK(main_widgets.notebook), NULL, 0, NULL);*/ + ui_set_window_title(NULL); + ui_save_buttons_toggle(FALSE); + ui_document_buttons_update(); + build_menu_update(NULL); } - geany_debug("Error: page_num: %d", page_num); - return FALSE; + return TRUE; }
Modified: branches/split-window-plugin/src/geanyobject.c =================================================================== --- branches/split-window-plugin/src/geanyobject.c 2008-09-10 14:49:16 UTC (rev 2935) +++ branches/split-window-plugin/src/geanyobject.c 2008-09-11 15:03:58 UTC (rev 2936) @@ -116,6 +116,15 @@ gtk_marshal_NONE__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER); + geany_object_signals[GCB_DOCUMENT_CLOSE] = g_signal_new ( + "document-close", + G_OBJECT_CLASS_TYPE (g_object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (GeanyObjectClass, document_close), + NULL, NULL, + gtk_marshal_NONE__POINTER, + G_TYPE_NONE, 1, + G_TYPE_POINTER);
geany_object_signals[GCB_PROJECT_OPEN] = g_signal_new ( "project-open", @@ -143,6 +152,7 @@ NULL, NULL, gtk_marshal_NONE__NONE, G_TYPE_NONE, 0); + geany_object_signals[GCB_UPDATE_EDITOR_MENU] = g_signal_new ( "update-editor-menu", G_OBJECT_CLASS_TYPE (g_object_class),
Modified: branches/split-window-plugin/src/geanyobject.h =================================================================== --- branches/split-window-plugin/src/geanyobject.h 2008-09-10 14:49:16 UTC (rev 2935) +++ branches/split-window-plugin/src/geanyobject.h 2008-09-11 15:03:58 UTC (rev 2936) @@ -38,6 +38,7 @@ GCB_DOCUMENT_OPEN, GCB_DOCUMENT_SAVE, GCB_DOCUMENT_ACTIVATE, + GCB_DOCUMENT_CLOSE, GCB_PROJECT_OPEN, GCB_PROJECT_SAVE, GCB_PROJECT_CLOSE, @@ -75,6 +76,7 @@ void (*document_open)(GeanyDocument *doc); void (*document_save)(GeanyDocument *doc); void (*document_activate)(GeanyDocument *doc); + void (*document_close)(GeanyDocument *doc); void (*project_open)(GKeyFile *keyfile); void (*project_save)(GKeyFile *keyfile); void (*project_close)(void);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.