GTK 3.20 doesn't like getting a style property for a non-current state,
unless the call is wrapped in a save()/restore() pair.
So, fix the code to either use the current state or temporarily save
the context.
gb.c now uses different states, but it shouldn't really matter given
how they are used, and even gives a native behavior when the window
loses focus, as it now properly reacts to BACKDROP state.
Both sorting by name and appearance makes sense for most languages. Some
users may prefer sorting by appearance so make it configurable in
preferences (the possibility to override the settings for specific
filetypes is preserved).
Thanks to Colomban Wendling for lots of improvements of this patch.
Fixes#313.
encodings.h had a pretty large GEANY_PRIVATE part so it's worthwhile to
separate that into its own header (as per HACKING). What's left is used by the
plugin API.
Colorizing the whole document is rather expensive and unnecessary as
Scintilla colorizes the visible part of the document when scrolling
happens. Instead, colorize only the visible area when highlighting
typenames.
6f5d5db and d6d4728 disabled "maintain history on reload" by default,
with the intention to reenable it when we have a better method to
make it discoverable for the user. This was necessary since it became
enabled by default but could be surprising given Geany warned about
losing data before.
This commit tries to resolve the discoverability, by providing an
informational doc message that is shown once to the user, after the first
reload. The doc message also gives the option to disable this feature.
GVFS uses different backends for "native" GIO operations and POSIX
operations which use the FUSE backend. If the two kinds of operations are
mixed, we may get races.
The patch checks the value of file_prefs.use_gio_unsafe_file_saving and
based on it either uses GIO operations or POSIX operations for file loading,
saving and checking modification time.
As the edited file can be a remote file on a server with a different time
zone, the mtime can actually be in the future. In this case the check not
only shows the misleading warning but more importantly the
doc->priv->mtime < st.st_mtime
check never happens and the user doesn't get the modified file prompt.
Setting
doc->priv->mtime = time(NULL);
to the current time on file creation isn't harmful in any way because the
saved file's mtime is taken but it's a bit misleading so better to set it
to 0.
This makes it easier to define it consistently to what the compiler
and platform supports, and avoids having to include a special header
everywhere, which is some kind of a problem for separate libraries
like TagManager and especially Scintilla.
As we only use these macros from the source and not the headers, it
is fine for it to be defined to a configure-time check from the build
system.
Warning: Although Waf and Windows makefiles are updated they are not
tested an will probably required tuning.
Adds a new header `pluginexport.h` to put the macros in, could be
moved into an existing header (support.h?) by I didn't want to drag
a bunch of existing stuff into the source files for this one macro.
TagManager has relative include, this could be fixed by changing the
include directories for it if it's a problem. Mark the Scintilla
functions exported by re-declaring them in sciwrappers.c with the
attribute to avoid changing upstream Scintilla code.
This actually fixes a theoretical bug introduced when notebook pages
stopped being ScintillaWidgets, but this bug had no effect because it
was in a dead code path -- because no, `page_num` never is -1 nor
`page` NULL.
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.
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.
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.
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.
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.
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.
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.
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
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.
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).
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.