652 Commits

Author SHA1 Message Date
Colomban Wendling
1a8de8fb09 Optimize document -> notebook page lookup 2015-02-21 18:53:59 +01:00
Colomban Wendling
99552dbe12 Fix emission of the ::document-activate signal
The ::document-activate signal was not emitted when opening the first
tab of the notebook, e.g. when the tab count changed from 0 to 1.

This is because the ::document-activate signal is emitted in response
to the GtkNotebook::switch-page signal, which is emitted whenever the
currently displayed page changes.  When there already is a current page
(when there is one or more pages), adding a new page does not trigger
the signal, as this new page doesn't become the current one (we will
switch to it later).  However, when there are none, the newly added one
becomes current, and so the signal is emitted right away.

This is problematic because when we add the page to the notebook, the
document associated with it is not yet ready (only partly initialized),
and so we can't emit the signal on a valid document, and we discard it.

Not emitting this signal leads to inconsistent behavior introducing
subtle bugs in plugins relying on it.

To work this around, only show the page widget (the child added to the
notebook) after we finished initializing everything.  This is the
simplest fix, because a lot of the code around document creation and
opening depend on the fact the page is already added, so while delaying
the page addition sounds like the more sensible fix, it has non-trivial
consequences that would require a large amount of work to overcome.

Note that interestingly, in addition to our problem, GtkNotebook seems
to have a bug as it emits the ::switch-page right when adding the first
page even if that page is not visible.  However, it properly emits it
again when the child becomes visible, so we just still discard the
first emission like we used to.
2015-02-21 18:49:09 +01:00
Thomas Martitz
7fba0317d0 document: Remove duplicated code.
Since document_compare_by_tab_order_reverse does the exact reverse of
document_compare_by_tab_order the code need not to be duplicated. Instead
document_compare_by_tab_order can be called and the return value be reversed.
2015-01-28 15:33:52 +01:00
Colomban Wendling
f403e7e8c2 Merge pull request #188 from artros/feature/keep-edit-history-on-reload
Maintain edit history on document reload

Conflicts:
 * src/callbacks.c: document_reload_prompt().

Amendments:
 * src/document.c: document_redo(), document_undo(): for loop style.
2015-01-28 15:16:40 +01:00
Colomban Wendling
44eecc25c3 Merge pull request #187 from artros/bug/clear-redo-on-edit
Clear redo stack on edit
2015-01-28 14:30:43 +01:00
Colomban Wendling
67cc8faf4b Fix closing of the "missing file" infobar
The issue was introduced in b646424ddb715382a937d233a75bc684c22e18ec as
it removed the default handler that used to destroy the infobar.

Now, the infobar is properly closed, but only if the action succeeded.

Closes #375.
2014-11-09 22:14:12 +01:00
Colomban Wendling
6a0673f4ae TM: Don't allow passing NULL to tm_workspace API 2014-11-08 18:32:41 +01:00
Jiří Techet
a95fc1a994 Don't expose the source file update function to plugins 2014-11-05 21:50:07 +01:00
Jiří Techet
71cc1ecb20 Cleaner and safer TMWorkspace API
With the previous TMWorkspace API it was possible to make the workspace
inconsistent by e.g. removing source files and forgetting to update
workspace. This could lead to non-obvious and not immediately visible
crashes.

The new set of the public (but also Geany private) API calls always
updates the workspace accordingly and neither of the calls can lead
to an inconsistent state of the workspace.

In addition, perform some minor cleanups and simplifications - unify
parsing from buffer and from file, support "parsing" of 0-sized buffers
and improve documentation.
2014-11-02 11:39:57 +01:00
Jiří Techet
bdee1336aa Keep a separate list of typenames for Scintilla syntax highlighting
Manage the list the same way as workspace tags_array by the fast tag removal
and merge. Thanks to this, typename tags don't have to be extracted from
tags_array periodically, which speeds up editing.
2014-10-30 22:08:17 +01:00
Jiří Techet
15c90b63c9 Get rid of lazy initialization in TM
Lazy initializing various member pointers doesn't bring any real performance
improvement but it requires lots of additional NULL checks - get rid of
this.

Make some more cleanups on the way.

In addition, remove success/failure return values from tm_workspace_add_source_file()
and tm_workspace_remove_source_file() which have no real use.
2014-10-30 22:08:17 +01:00
Jiří Techet
43b8ab8d23 Only keep the minimal set of parameter in the TM API calls
Avoid "utility" parameters like do_free for which we already have API calls
and which actually don't perform any free if the source file isn't
in TM. Clarify when to set the update_workspace parameter.
2014-10-30 22:08:17 +01:00
Jiří Techet
0285ec28a5 Move tm_source_file_update() to tm_workspace.c
The placement of this function in tm_source_file is not right - by moving
it to the workspace we can make the source file unaware of the existence
of the workspace (no inclusion of tm_workspace.h in tm_source_file any
more). Also change tm_source_file_new() so it doesn't offer the source file
update.

After this change
* TMWorkspace knows TMSourceFile and TMTag
* TMSourceFile knows TMTag
* TMTag knows TMSourceFile
2014-10-30 22:08:17 +01:00
Jiří Techet
26587454b0 Remove TmWorkObject and all the OO related stuff
In addition, rename all functions, parameters, comments etc. mentioning
work_object and remove unnecessary parameters of various functions.
Delete dead code paths.

Also move common functions like tm_get_real_path() from tm_work_object to
tm_source_file.
2014-10-18 21:40:10 +02:00
Colomban Wendling
75ab7103f1 Merge pull request #353 from b4n/tm-no-update-on-quit
Don't rebuild TagManager workspace tags when quitting
2014-10-12 16:02:40 +02:00
Colomban Wendling
f1da4b9914 Don't rebuild TagManager workspace tags when quitting
Updating the workspace is useless as the application will be shut down,
and not doing it can save a lot of time (almost 50% speedup quitting an
instance with all Geany source from `src/` open).
2014-10-11 01:40:10 +02:00
Nick Treleaven
ab7a0018b2 Don't prompt for reload from infobar when there are no unsaved changes
Also warn about losing undo history when there are no changes.
2014-10-10 16:59:43 +01:00
Nick Treleaven
541cb8dbcc Force disk check before save to prevent accidental overwriting
Useful e.g. with Save All when the modified file is not the current tab.
2014-09-30 17:10:53 +01:00
Nick Treleaven
3ab6579091 Notify user when trying to save read-only document 2014-09-26 11:44:07 +01:00
Nick Treleaven
4ceb9fb1f2 Add comment about throwing away read-only for renamed documents 2014-09-26 11:44:05 +01:00
Nick Treleaven
9d669a72f7 API: Rename document_reload_file -> document_reload_force
New name is clearer against document_reload_prompt.
Add deprecated alias.
2014-09-25 11:45:49 +01:00
Nick Treleaven
b646424ddb Only close reload infobar if the response succeeded 2014-09-24 12:21:32 +01:00
Nick Treleaven
3830240cb8 Confirm info-bar reload when document has modifications 2014-09-24 12:21:30 +01:00
Nick Treleaven
0a80a72f0b Set status id to STATUS_DISK_CHANGED when protecting document 2014-09-24 12:08:40 +01:00
Nick Treleaven
9a02525d1c Don't set document text as changed when file on disk is newer
Setting the document text as changed makes it too easy to accidentally
overwrite the file - e.g. when closing you're reminded to save it.
It also makes it slower to close documents you no longer want open.
Setting text as changed is still done if the user cancels the warning.
2014-09-24 12:08:24 +01:00
Nick Treleaven
06e40e512f Confirm whether to save protected documents
(Reuses existing strings).
2014-09-23 14:53:08 +01:00
Nick Treleaven
7450a992b5 Use 'Overwrite' rather than Save for clarity in reload infobar 2014-09-23 14:43:49 +01:00
Thomas Martitz
a6d11cb4f8 Use custom document info bar response IDs 2014-09-23 14:43:47 +01:00
Colomban Wendling
666fdf30fa Document document_find_by_id() parameter so Doxygen is happy 2014-08-29 17:06:51 +02:00
Nick Treleaven
18181c2e90 Support pseudo-unique IDs for documents
Add GeanyDocument::id, document_find_by_id() to plugin API.

This also fixes clicking on a Messages item whose document has been
closed and reused. Now the click will be ignored instead of jumping to
an unexpected line in the new document.
2014-08-19 15:40:05 +01:00
Colomban Wendling
dc140165ae Use GeanyFindFlags instead of plain integer when expecting Geany find flags
This makes the API more obvious on what argument is expected, and avoid
confusion between Geany and Scintilla find flags.
2014-08-19 03:42:58 +02:00
Colomban Wendling
bdc0f720e7 Remove unused flags from document_search_bar_find()
Passed-in flags was always 0, so the argument is not useful.
Also, this function expected Scintilla search flags rather than Geany
ones, making the API confusing for no good reason.
2014-08-19 03:40:52 +02:00
Colomban Wendling
593b9dd2c9 Merge branch 'single-line-regex' 2014-08-10 01:51:48 +02:00
Colomban Wendling
482d2732af Add support for single-line regular expressions 2014-08-10 01:46:16 +02:00
Colomban Wendling
a26bdd628f Fix crash when closing a document with visible infobars
Apparently the ::unrealize symbol is sent too late, after we destroyed
the widget and freed the GeanyDocument, and some signals like
::focus-in-event can still be fired on the widget after that.

So, properly use the ::destroy signal that is supposed to be fired when
others should release references to that instance.
2014-08-07 15:14:22 +02:00
Nick Treleaven
e1988964c1 Fix Windows build 2014-08-01 12:05:30 +01:00
Nick Treleaven
01b3103eaf Remove unread variable 2014-08-01 11:54:05 +01:00
Colomban Wendling
b65f49902f Fix closing the documents when quitting
When quitting we avoid doing some unnecessary actions, and used to
simply destroy the Scintilla widget (and thus the notebook page)
instead of the elaborate UI updates.

Unfortunately, when the infobars landed they changed what is packed as
a notebook page, and now destroying the Scintilla widget alone is not
enough to close the page.  Fix this by properly removing the whole page
no matter what it contains.

This issue was visible when quitting Geany with a project open.
2014-07-26 15:03:49 +02:00
Colomban Wendling
0682a25585 Fix crash when quitting with an infobar visible
When the infobar gets closed/destroyed it tries to focus the possibly
destroyed document, leading to a crash.
2014-07-26 13:36:19 +02:00
Thomas Martitz
ffcec43d01 document.c: Immediately mark as changed when document is externally deleted
Before infobar it didn't matter because the dialog was modal and interaction
with the doc was impossible. Now that you can interact it the doc should
be marked changed immediately.
2014-06-29 11:38:02 +02:00
Thomas Martitz
0f7db113e7 document.c: Restore lost document_set_text_changed(doc, TRUE) call
It got lost by accident in 5117940.
2014-06-29 11:38:02 +02:00
Thomas Martitz
c8970e2331 info bars: Show additional save button for the "reload file?" info bar
This allows overwriting the file right from the info bar.
2014-06-29 11:38:02 +02:00
Thomas Martitz
4b8f42cd9e info bars: Explicitely move focus back to the editor when closing
This does not seem to happen automatically, at least on GTK3.
2014-06-29 11:37:47 +02:00
Thomas Martitz
ab42662309 Fix racy glib assertion failure
Use g_signal_connect_object() to establish automatic and race-free signal
disconnection instead of the hand-crafted mechanism.
2014-06-29 11:29:07 +02:00
Colomban Wendling
35a212dffc Merge branch 'callbacks-cleanup' 2014-06-27 22:32:38 +02:00
Colomban Wendling
3ce25db632 Remove line number zoom hack as it is no longer necessary
Since cbf9813632d7ee921ffa1fda0d1f69128b2bc755 we have a proper
solution for maintaining line number consistent with the editor zoom,
so drop the old hack.

This also allows to remove the now useless third argument of
sci_set_line_numbers().
2014-06-27 22:23:48 +02:00
Thomas Martitz
721769e682 Fix build warning about missing return value. 2014-06-24 23:07:08 +02:00
Colomban Wendling
cc2f1879a8 Add printf attribute to document_show_message() for better safety
Add G_GNUC_PRINTF attribute to document_show_message() so some
compilers can check the format arguments match the format string.
2014-06-24 18:30:54 +02:00
Colomban Wendling
9bf647c5c3 Move on_clone1_activate() to callbacks.c 2014-06-24 18:26:44 +02:00
Thomas Martitz
135b60d25e callbacks: Refactor on_reload_as_activate() as document_reload_prompt()
The callback wasn't used from glade but is useful for some other places so
it's worth moving into document.c. This also fixes a bug where reload via sidebar
always reloads the current document instead of the actually clicked one.
2014-06-24 15:01:42 +02:00