Jason Cumbie
2018-05-13 16:11:24 UTC
Thanks for the quick reply!
Let me know if that didn't work.
'document-close' signal isn't emitted. I see that just fine. The issue is
that the document pointer that is sent in doesn't preserve the current
'changed' state of the document when it is closed when exiting Geany.
The reason for that is the 'document_account_for_saved' function that
is called when using 'document_close_all':
gboolean document_account_for_unsaved(void)
{
guint i, p, page_count;
page_count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.notebook));
/* iterate over documents in tabs order */
for (p = 0; p < page_count; p++)
{
GeanyDocument *doc = document_get_from_page(p);
if (DOC_VALID(doc) && doc->changed)
{
if (! dialogs_show_unsaved_file(doc))
return FALSE;
}
}
/* all documents should now be accounted for, so ignore any changes */
foreach_document (i)
{
documents[i]->changed = FALSE; // <----------------- this
alters close state when closing
}
return TRUE;
}
Thanks
Jason
The best way of providing for changes would be to make a pull request
on Github. Then they will at least be CI checked.
I set up an account and made a pull request so you can see the changes.on Github. Then they will at least be CI checked.
Let me know if that didn't work.
Also on Github you can point to parts of the source which support your
explanation, I can't immediately see where having "changed" false
stops the signal being emitted.
Apologies for the miscommunication. I didn't mean that theexplanation, I can't immediately see where having "changed" false
stops the signal being emitted.
'document-close' signal isn't emitted. I see that just fine. The issue is
that the document pointer that is sent in doesn't preserve the current
'changed' state of the document when it is closed when exiting Geany.
The reason for that is the 'document_account_for_saved' function that
is called when using 'document_close_all':
gboolean document_account_for_unsaved(void)
{
guint i, p, page_count;
page_count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.notebook));
/* iterate over documents in tabs order */
for (p = 0; p < page_count; p++)
{
GeanyDocument *doc = document_get_from_page(p);
if (DOC_VALID(doc) && doc->changed)
{
if (! dialogs_show_unsaved_file(doc))
return FALSE;
}
}
/* all documents should now be accounted for, so ignore any changes */
foreach_document (i)
{
documents[i]->changed = FALSE; // <----------------- this
alters close state when closing
}
return TRUE;
}
Thanks
Jason
Send Devel mailing list submissions to
To subscribe or unsubscribe via the World Wide Web, visit
https://lists.geany.org/cgi-bin/mailman/listinfo/devel
or, via email, send a message with subject or body 'help' to
You can reach the person managing the list at
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Devel digest..."
1. Geany Plugins and Document Close Behavior (Jason Cumbie)
2. Re: Geany Plugins and Document Close Behavior (Lex Trotman)
3. Re: Geany Plugins and Document Close Behavior (Lex Trotman)
----------------------------------------------------------------------
Message: 1
Date: Sat, 12 May 2018 23:55:20 -0700
Subject: [Geany-Devel] Geany Plugins and Document Close Behavior
Content-Type: text/plain; charset="utf-8"
Hello Geany Developers,
I’m a software developer who has had fun using Geany for my own
projects, so thank you for all the hard work you guys have been doing
- I love it! Hopefully this is the right place to post this - if there
is somewhere else I should post this additionally and/or instead let
me know.
When playing around with modifying plugins I found a potential issue
with document closing. The ‘document-close’ signal only supplies
plugins with a document that has the ‘changed’ flag set if one
document is closed, e.g. a user hit the 'x' on the UI document tab,
but not when all documents are being closed, e.g. when quitting Geany,
regardless of whether the ‘document’ has changes. The cause for this
behavior appears to be the 'document_account_for_saved' function in
document.c which sets the 'changed' flag to FALSE when closing all
documents. I've attached a patch to this email that could address
this. At the bottom of this email I've described the approach I took
with this patch. If the patch doesn’t look good let me know what I
can do to fix it, or if this behavior is expected, would love
suggestions on how a plugin should be able to get this information
when a document is being closed.
I'm running Geany by installing it from source from the most recent
version: 1.34., but the behavior I see is caused by functions and code
which appear to have been around for awhile so I don't think this
would be much different for previous versions.
Thank you for any feedback you guys can give. Again really love the
Geany project, and I’m glad you’ve made it possible to have fun coding
without requiring shelling out massive amounts of money to use a
really nice light-weight editor.
Jason
The approach in the patch is simple – remove the code that modifies
the ‘changed’ flag in 'document_account_for_saved', and add a check in
the ‘remove_page’ function for the ‘main_status.closing_all’ to avoid
prompting the user when closing all documents. This flag gets set
during ‘force_close_all’ which is only called in ‘document_close_all’,
so I couldn’t find anything wrong with this approach – let me know if
that is not the case.
The only other change that was needed is in how ‘main_quit’ handles
closing all documents to ensure the current behavior behavior isn’t
changed when closing Geany, especially since it also calls
‘document_account_for_unsaved’. The approach I took to this was to
remove the ‘document_account_for_unsaved’ out of the ‘main_quit’
function since this will be called with ‘project_close’ or
‘document_close_all’ in 'do_main_quit', and change the ‘do_main_quit’
function to use the return value from ‘project_close’ and/or
‘document_close_all’ to allow aborting the procedure if the user
canceled and pass this back up to the ‘main_quit’ , or return TRUE at
the end of the function call otherwise.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: document-close.patch
Type: text/x-patch
Size: 2232 bytes
Desc: not available
URL: <https://lists.geany.org/pipermail/devel/attachments/20180512/f1023363/attachment-0001.bin>
------------------------------
Message: 2
Date: Sun, 13 May 2018 17:35:47 +1000
Subject: Re: [Geany-Devel] Geany Plugins and Document Close Behavior
Content-Type: text/plain; charset="UTF-8"
Hi,
The best way of providing for changes would be to make a pull request
on Github. Then they will at least be CI checked.
Cheers
Lex
Message: 3
Date: Sun, 13 May 2018 17:50:55 +1000
Subject: Re: [Geany-Devel] Geany Plugins and Document Close Behavior
Content-Type: text/plain; charset="UTF-8"
explanation, I can't immediately see where having "changed" false
stops the signal being emitted.
Cheers
Lex
Subject: Digest Footer
_______________________________________________
Devel mailing list
https://lists.geany.org/cgi-bin/mailman/listinfo/devel
------------------------------
End of Devel Digest, Vol 121, Issue 1
*************************************
To subscribe or unsubscribe via the World Wide Web, visit
https://lists.geany.org/cgi-bin/mailman/listinfo/devel
or, via email, send a message with subject or body 'help' to
You can reach the person managing the list at
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Devel digest..."
1. Geany Plugins and Document Close Behavior (Jason Cumbie)
2. Re: Geany Plugins and Document Close Behavior (Lex Trotman)
3. Re: Geany Plugins and Document Close Behavior (Lex Trotman)
----------------------------------------------------------------------
Message: 1
Date: Sat, 12 May 2018 23:55:20 -0700
Subject: [Geany-Devel] Geany Plugins and Document Close Behavior
Content-Type: text/plain; charset="utf-8"
Hello Geany Developers,
I’m a software developer who has had fun using Geany for my own
projects, so thank you for all the hard work you guys have been doing
- I love it! Hopefully this is the right place to post this - if there
is somewhere else I should post this additionally and/or instead let
me know.
When playing around with modifying plugins I found a potential issue
with document closing. The ‘document-close’ signal only supplies
plugins with a document that has the ‘changed’ flag set if one
document is closed, e.g. a user hit the 'x' on the UI document tab,
but not when all documents are being closed, e.g. when quitting Geany,
regardless of whether the ‘document’ has changes. The cause for this
behavior appears to be the 'document_account_for_saved' function in
document.c which sets the 'changed' flag to FALSE when closing all
documents. I've attached a patch to this email that could address
this. At the bottom of this email I've described the approach I took
with this patch. If the patch doesn’t look good let me know what I
can do to fix it, or if this behavior is expected, would love
suggestions on how a plugin should be able to get this information
when a document is being closed.
I'm running Geany by installing it from source from the most recent
version: 1.34., but the behavior I see is caused by functions and code
which appear to have been around for awhile so I don't think this
would be much different for previous versions.
Thank you for any feedback you guys can give. Again really love the
Geany project, and I’m glad you’ve made it possible to have fun coding
without requiring shelling out massive amounts of money to use a
really nice light-weight editor.
Jason
The approach in the patch is simple – remove the code that modifies
the ‘changed’ flag in 'document_account_for_saved', and add a check in
the ‘remove_page’ function for the ‘main_status.closing_all’ to avoid
prompting the user when closing all documents. This flag gets set
during ‘force_close_all’ which is only called in ‘document_close_all’,
so I couldn’t find anything wrong with this approach – let me know if
that is not the case.
The only other change that was needed is in how ‘main_quit’ handles
closing all documents to ensure the current behavior behavior isn’t
changed when closing Geany, especially since it also calls
‘document_account_for_unsaved’. The approach I took to this was to
remove the ‘document_account_for_unsaved’ out of the ‘main_quit’
function since this will be called with ‘project_close’ or
‘document_close_all’ in 'do_main_quit', and change the ‘do_main_quit’
function to use the return value from ‘project_close’ and/or
‘document_close_all’ to allow aborting the procedure if the user
canceled and pass this back up to the ‘main_quit’ , or return TRUE at
the end of the function call otherwise.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: document-close.patch
Type: text/x-patch
Size: 2232 bytes
Desc: not available
URL: <https://lists.geany.org/pipermail/devel/attachments/20180512/f1023363/attachment-0001.bin>
------------------------------
Message: 2
Date: Sun, 13 May 2018 17:35:47 +1000
Subject: Re: [Geany-Devel] Geany Plugins and Document Close Behavior
Content-Type: text/plain; charset="UTF-8"
Hi,
The best way of providing for changes would be to make a pull request
on Github. Then they will at least be CI checked.
Cheers
Lex
Hello Geany Developers,
I’m a software developer who has had fun using Geany for my own
projects, so thank you for all the hard work you guys have been doing
- I love it! Hopefully this is the right place to post this - if there
is somewhere else I should post this additionally and/or instead let
me know.
When playing around with modifying plugins I found a potential issue
with document closing. The ‘document-close’ signal only supplies
plugins with a document that has the ‘changed’ flag set if one
document is closed, e.g. a user hit the 'x' on the UI document tab,
but not when all documents are being closed, e.g. when quitting Geany,
regardless of whether the ‘document’ has changes. The cause for this
behavior appears to be the 'document_account_for_saved' function in
document.c which sets the 'changed' flag to FALSE when closing all
documents. I've attached a patch to this email that could address
this. At the bottom of this email I've described the approach I took
with this patch. If the patch doesn’t look good let me know what I
can do to fix it, or if this behavior is expected, would love
suggestions on how a plugin should be able to get this information
when a document is being closed.
I'm running Geany by installing it from source from the most recent
version: 1.34., but the behavior I see is caused by functions and code
which appear to have been around for awhile so I don't think this
would be much different for previous versions.
Thank you for any feedback you guys can give. Again really love the
Geany project, and I’m glad you’ve made it possible to have fun coding
without requiring shelling out massive amounts of money to use a
really nice light-weight editor.
Jason
The approach in the patch is simple – remove the code that modifies
the ‘changed’ flag in 'document_account_for_saved', and add a check in
the ‘remove_page’ function for the ‘main_status.closing_all’ to avoid
prompting the user when closing all documents. This flag gets set
during ‘force_close_all’ which is only called in ‘document_close_all’,
so I couldn’t find anything wrong with this approach – let me know if
that is not the case.
The only other change that was needed is in how ‘main_quit’ handles
closing all documents to ensure the current behavior behavior isn’t
changed when closing Geany, especially since it also calls
‘document_account_for_unsaved’. The approach I took to this was to
remove the ‘document_account_for_unsaved’ out of the ‘main_quit’
function since this will be called with ‘project_close’ or
‘document_close_all’ in 'do_main_quit', and change the ‘do_main_quit’
function to use the return value from ‘project_close’ and/or
‘document_close_all’ to allow aborting the procedure if the user
canceled and pass this back up to the ‘main_quit’ , or return TRUE at
the end of the function call otherwise.
_______________________________________________
Devel mailing list
https://lists.geany.org/cgi-bin/mailman/listinfo/devel
------------------------------I’m a software developer who has had fun using Geany for my own
projects, so thank you for all the hard work you guys have been doing
- I love it! Hopefully this is the right place to post this - if there
is somewhere else I should post this additionally and/or instead let
me know.
When playing around with modifying plugins I found a potential issue
with document closing. The ‘document-close’ signal only supplies
plugins with a document that has the ‘changed’ flag set if one
document is closed, e.g. a user hit the 'x' on the UI document tab,
but not when all documents are being closed, e.g. when quitting Geany,
regardless of whether the ‘document’ has changes. The cause for this
behavior appears to be the 'document_account_for_saved' function in
document.c which sets the 'changed' flag to FALSE when closing all
documents. I've attached a patch to this email that could address
this. At the bottom of this email I've described the approach I took
with this patch. If the patch doesn’t look good let me know what I
can do to fix it, or if this behavior is expected, would love
suggestions on how a plugin should be able to get this information
when a document is being closed.
I'm running Geany by installing it from source from the most recent
version: 1.34., but the behavior I see is caused by functions and code
which appear to have been around for awhile so I don't think this
would be much different for previous versions.
Thank you for any feedback you guys can give. Again really love the
Geany project, and I’m glad you’ve made it possible to have fun coding
without requiring shelling out massive amounts of money to use a
really nice light-weight editor.
Jason
The approach in the patch is simple – remove the code that modifies
the ‘changed’ flag in 'document_account_for_saved', and add a check in
the ‘remove_page’ function for the ‘main_status.closing_all’ to avoid
prompting the user when closing all documents. This flag gets set
during ‘force_close_all’ which is only called in ‘document_close_all’,
so I couldn’t find anything wrong with this approach – let me know if
that is not the case.
The only other change that was needed is in how ‘main_quit’ handles
closing all documents to ensure the current behavior behavior isn’t
changed when closing Geany, especially since it also calls
‘document_account_for_unsaved’. The approach I took to this was to
remove the ‘document_account_for_unsaved’ out of the ‘main_quit’
function since this will be called with ‘project_close’ or
‘document_close_all’ in 'do_main_quit', and change the ‘do_main_quit’
function to use the return value from ‘project_close’ and/or
‘document_close_all’ to allow aborting the procedure if the user
canceled and pass this back up to the ‘main_quit’ , or return TRUE at
the end of the function call otherwise.
_______________________________________________
Devel mailing list
https://lists.geany.org/cgi-bin/mailman/listinfo/devel
Message: 3
Date: Sun, 13 May 2018 17:50:55 +1000
Subject: Re: [Geany-Devel] Geany Plugins and Document Close Behavior
Content-Type: text/plain; charset="UTF-8"
Hi,
The best way of providing for changes would be to make a pull request
on Github. Then they will at least be CI checked.
Also on Github you can point to parts of the source which support yourThe best way of providing for changes would be to make a pull request
on Github. Then they will at least be CI checked.
explanation, I can't immediately see where having "changed" false
stops the signal being emitted.
Cheers
Lex
Cheers
Lex
------------------------------Lex
Hello Geany Developers,
I’m a software developer who has had fun using Geany for my own
projects, so thank you for all the hard work you guys have been doing
- I love it! Hopefully this is the right place to post this - if there
is somewhere else I should post this additionally and/or instead let
me know.
When playing around with modifying plugins I found a potential issue
with document closing. The ‘document-close’ signal only supplies
plugins with a document that has the ‘changed’ flag set if one
document is closed, e.g. a user hit the 'x' on the UI document tab,
but not when all documents are being closed, e.g. when quitting Geany,
regardless of whether the ‘document’ has changes. The cause for this
behavior appears to be the 'document_account_for_saved' function in
document.c which sets the 'changed' flag to FALSE when closing all
documents. I've attached a patch to this email that could address
this. At the bottom of this email I've described the approach I took
with this patch. If the patch doesn’t look good let me know what I
can do to fix it, or if this behavior is expected, would love
suggestions on how a plugin should be able to get this information
when a document is being closed.
I'm running Geany by installing it from source from the most recent
version: 1.34., but the behavior I see is caused by functions and code
which appear to have been around for awhile so I don't think this
would be much different for previous versions.
Thank you for any feedback you guys can give. Again really love the
Geany project, and I’m glad you’ve made it possible to have fun coding
without requiring shelling out massive amounts of money to use a
really nice light-weight editor.
Jason
The approach in the patch is simple – remove the code that modifies
the ‘changed’ flag in 'document_account_for_saved', and add a check in
the ‘remove_page’ function for the ‘main_status.closing_all’ to avoid
prompting the user when closing all documents. This flag gets set
during ‘force_close_all’ which is only called in ‘document_close_all’,
so I couldn’t find anything wrong with this approach – let me know if
that is not the case.
The only other change that was needed is in how ‘main_quit’ handles
closing all documents to ensure the current behavior behavior isn’t
changed when closing Geany, especially since it also calls
‘document_account_for_unsaved’. The approach I took to this was to
remove the ‘document_account_for_unsaved’ out of the ‘main_quit’
function since this will be called with ‘project_close’ or
‘document_close_all’ in 'do_main_quit', and change the ‘do_main_quit’
function to use the return value from ‘project_close’ and/or
‘document_close_all’ to allow aborting the procedure if the user
canceled and pass this back up to the ‘main_quit’ , or return TRUE at
the end of the function call otherwise.
_______________________________________________
Devel mailing list
https://lists.geany.org/cgi-bin/mailman/listinfo/devel
I’m a software developer who has had fun using Geany for my own
projects, so thank you for all the hard work you guys have been doing
- I love it! Hopefully this is the right place to post this - if there
is somewhere else I should post this additionally and/or instead let
me know.
When playing around with modifying plugins I found a potential issue
with document closing. The ‘document-close’ signal only supplies
plugins with a document that has the ‘changed’ flag set if one
document is closed, e.g. a user hit the 'x' on the UI document tab,
but not when all documents are being closed, e.g. when quitting Geany,
regardless of whether the ‘document’ has changes. The cause for this
behavior appears to be the 'document_account_for_saved' function in
document.c which sets the 'changed' flag to FALSE when closing all
documents. I've attached a patch to this email that could address
this. At the bottom of this email I've described the approach I took
with this patch. If the patch doesn’t look good let me know what I
can do to fix it, or if this behavior is expected, would love
suggestions on how a plugin should be able to get this information
when a document is being closed.
I'm running Geany by installing it from source from the most recent
version: 1.34., but the behavior I see is caused by functions and code
which appear to have been around for awhile so I don't think this
would be much different for previous versions.
Thank you for any feedback you guys can give. Again really love the
Geany project, and I’m glad you’ve made it possible to have fun coding
without requiring shelling out massive amounts of money to use a
really nice light-weight editor.
Jason
The approach in the patch is simple – remove the code that modifies
the ‘changed’ flag in 'document_account_for_saved', and add a check in
the ‘remove_page’ function for the ‘main_status.closing_all’ to avoid
prompting the user when closing all documents. This flag gets set
during ‘force_close_all’ which is only called in ‘document_close_all’,
so I couldn’t find anything wrong with this approach – let me know if
that is not the case.
The only other change that was needed is in how ‘main_quit’ handles
closing all documents to ensure the current behavior behavior isn’t
changed when closing Geany, especially since it also calls
‘document_account_for_unsaved’. The approach I took to this was to
remove the ‘document_account_for_unsaved’ out of the ‘main_quit’
function since this will be called with ‘project_close’ or
‘document_close_all’ in 'do_main_quit', and change the ‘do_main_quit’
function to use the return value from ‘project_close’ and/or
‘document_close_all’ to allow aborting the procedure if the user
canceled and pass this back up to the ‘main_quit’ , or return TRUE at
the end of the function call otherwise.
_______________________________________________
Devel mailing list
https://lists.geany.org/cgi-bin/mailman/listinfo/devel
Subject: Digest Footer
_______________________________________________
Devel mailing list
https://lists.geany.org/cgi-bin/mailman/listinfo/devel
------------------------------
End of Devel Digest, Vol 121, Issue 1
*************************************