Adding upstream version 48.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
__pycache__/
|
3
.gitmodules
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule "subprojects/libgd"]
|
||||||
|
path = subprojects/libgd
|
||||||
|
url = https://gitlab.gnome.org/GNOME/libgd.git
|
34
CONTRIBUTING.md
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
How to contribute to gedit
|
||||||
|
==========================
|
||||||
|
|
||||||
|
gedit development relies on voluntary contributions and everyone is invited to
|
||||||
|
help.
|
||||||
|
|
||||||
|
If you are interested in helping us to improve gedit, you can contact the
|
||||||
|
developers, see the “Getting in Touch” section on the
|
||||||
|
[gedit web page](https://gedit-technology.github.io/apps/gedit/).
|
||||||
|
|
||||||
|
Software development
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
To get started with gedit development, see the file
|
||||||
|
[docs/gedit-development-getting-started.md](docs/gedit-development-getting-started.md).
|
||||||
|
|
||||||
|
Contributions other than software development
|
||||||
|
---------------------------------------------
|
||||||
|
|
||||||
|
See: https://welcome.gnome.org/
|
||||||
|
|
||||||
|
There are many possible tasks:
|
||||||
|
- Doing bug triaging on the bug tracker.
|
||||||
|
- Improving the documentation.
|
||||||
|
- Translations.
|
||||||
|
- Graphics design.
|
||||||
|
- Helping other users.
|
||||||
|
- Sharing news and tips about gedit in your native language / local community.
|
||||||
|
- Etc.
|
||||||
|
|
||||||
|
Useful links
|
||||||
|
------------
|
||||||
|
|
||||||
|
- https://handbook.gnome.org/
|
340
COPYING
Normal file
|
@ -0,0 +1,340 @@
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 2, June 1991
|
||||||
|
|
||||||
|
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The licenses for most software are designed to take away your
|
||||||
|
freedom to share and change it. By contrast, the GNU General Public
|
||||||
|
License is intended to guarantee your freedom to share and change free
|
||||||
|
software--to make sure the software is free for all its users. This
|
||||||
|
General Public License applies to most of the Free Software
|
||||||
|
Foundation's software and to any other program whose authors commit to
|
||||||
|
using it. (Some other Free Software Foundation software is covered by
|
||||||
|
the GNU Lesser General Public License instead.) You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
this service if you wish), that you receive source code or can get it
|
||||||
|
if you want it, that you can change the software or use pieces of it
|
||||||
|
in new free programs; and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to make restrictions that forbid
|
||||||
|
anyone to deny you these rights or to ask you to surrender the rights.
|
||||||
|
These restrictions translate to certain responsibilities for you if you
|
||||||
|
distribute copies of the software, or if you modify it.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must give the recipients all the rights that
|
||||||
|
you have. You must make sure that they, too, receive or can get the
|
||||||
|
source code. And you must show them these terms so they know their
|
||||||
|
rights.
|
||||||
|
|
||||||
|
We protect your rights with two steps: (1) copyright the software, and
|
||||||
|
(2) offer you this license which gives you legal permission to copy,
|
||||||
|
distribute and/or modify the software.
|
||||||
|
|
||||||
|
Also, for each author's protection and ours, we want to make certain
|
||||||
|
that everyone understands that there is no warranty for this free
|
||||||
|
software. If the software is modified by someone else and passed on, we
|
||||||
|
want its recipients to know that what they have is not the original, so
|
||||||
|
that any problems introduced by others will not reflect on the original
|
||||||
|
authors' reputations.
|
||||||
|
|
||||||
|
Finally, any free program is threatened constantly by software
|
||||||
|
patents. We wish to avoid the danger that redistributors of a free
|
||||||
|
program will individually obtain patent licenses, in effect making the
|
||||||
|
program proprietary. To prevent this, we have made it clear that any
|
||||||
|
patent must be licensed for everyone's free use or not licensed at all.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||||
|
|
||||||
|
0. This License applies to any program or other work which contains
|
||||||
|
a notice placed by the copyright holder saying it may be distributed
|
||||||
|
under the terms of this General Public License. The "Program", below,
|
||||||
|
refers to any such program or work, and a "work based on the Program"
|
||||||
|
means either the Program or any derivative work under copyright law:
|
||||||
|
that is to say, a work containing the Program or a portion of it,
|
||||||
|
either verbatim or with modifications and/or translated into another
|
||||||
|
language. (Hereinafter, translation is included without limitation in
|
||||||
|
the term "modification".) Each licensee is addressed as "you".
|
||||||
|
|
||||||
|
Activities other than copying, distribution and modification are not
|
||||||
|
covered by this License; they are outside its scope. The act of
|
||||||
|
running the Program is not restricted, and the output from the Program
|
||||||
|
is covered only if its contents constitute a work based on the
|
||||||
|
Program (independent of having been made by running the Program).
|
||||||
|
Whether that is true depends on what the Program does.
|
||||||
|
|
||||||
|
1. You may copy and distribute verbatim copies of the Program's
|
||||||
|
source code as you receive it, in any medium, provided that you
|
||||||
|
conspicuously and appropriately publish on each copy an appropriate
|
||||||
|
copyright notice and disclaimer of warranty; keep intact all the
|
||||||
|
notices that refer to this License and to the absence of any warranty;
|
||||||
|
and give any other recipients of the Program a copy of this License
|
||||||
|
along with the Program.
|
||||||
|
|
||||||
|
You may charge a fee for the physical act of transferring a copy, and
|
||||||
|
you may at your option offer warranty protection in exchange for a fee.
|
||||||
|
|
||||||
|
2. You may modify your copy or copies of the Program or any portion
|
||||||
|
of it, thus forming a work based on the Program, and copy and
|
||||||
|
distribute such modifications or work under the terms of Section 1
|
||||||
|
above, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) You must cause the modified files to carry prominent notices
|
||||||
|
stating that you changed the files and the date of any change.
|
||||||
|
|
||||||
|
b) You must cause any work that you distribute or publish, that in
|
||||||
|
whole or in part contains or is derived from the Program or any
|
||||||
|
part thereof, to be licensed as a whole at no charge to all third
|
||||||
|
parties under the terms of this License.
|
||||||
|
|
||||||
|
c) If the modified program normally reads commands interactively
|
||||||
|
when run, you must cause it, when started running for such
|
||||||
|
interactive use in the most ordinary way, to print or display an
|
||||||
|
announcement including an appropriate copyright notice and a
|
||||||
|
notice that there is no warranty (or else, saying that you provide
|
||||||
|
a warranty) and that users may redistribute the program under
|
||||||
|
these conditions, and telling the user how to view a copy of this
|
||||||
|
License. (Exception: if the Program itself is interactive but
|
||||||
|
does not normally print such an announcement, your work based on
|
||||||
|
the Program is not required to print an announcement.)
|
||||||
|
|
||||||
|
These requirements apply to the modified work as a whole. If
|
||||||
|
identifiable sections of that work are not derived from the Program,
|
||||||
|
and can be reasonably considered independent and separate works in
|
||||||
|
themselves, then this License, and its terms, do not apply to those
|
||||||
|
sections when you distribute them as separate works. But when you
|
||||||
|
distribute the same sections as part of a whole which is a work based
|
||||||
|
on the Program, the distribution of the whole must be on the terms of
|
||||||
|
this License, whose permissions for other licensees extend to the
|
||||||
|
entire whole, and thus to each and every part regardless of who wrote it.
|
||||||
|
|
||||||
|
Thus, it is not the intent of this section to claim rights or contest
|
||||||
|
your rights to work written entirely by you; rather, the intent is to
|
||||||
|
exercise the right to control the distribution of derivative or
|
||||||
|
collective works based on the Program.
|
||||||
|
|
||||||
|
In addition, mere aggregation of another work not based on the Program
|
||||||
|
with the Program (or with a work based on the Program) on a volume of
|
||||||
|
a storage or distribution medium does not bring the other work under
|
||||||
|
the scope of this License.
|
||||||
|
|
||||||
|
3. You may copy and distribute the Program (or a work based on it,
|
||||||
|
under Section 2) in object code or executable form under the terms of
|
||||||
|
Sections 1 and 2 above provided that you also do one of the following:
|
||||||
|
|
||||||
|
a) Accompany it with the complete corresponding machine-readable
|
||||||
|
source code, which must be distributed under the terms of Sections
|
||||||
|
1 and 2 above on a medium customarily used for software interchange; or,
|
||||||
|
|
||||||
|
b) Accompany it with a written offer, valid for at least three
|
||||||
|
years, to give any third party, for a charge no more than your
|
||||||
|
cost of physically performing source distribution, a complete
|
||||||
|
machine-readable copy of the corresponding source code, to be
|
||||||
|
distributed under the terms of Sections 1 and 2 above on a medium
|
||||||
|
customarily used for software interchange; or,
|
||||||
|
|
||||||
|
c) Accompany it with the information you received as to the offer
|
||||||
|
to distribute corresponding source code. (This alternative is
|
||||||
|
allowed only for noncommercial distribution and only if you
|
||||||
|
received the program in object code or executable form with such
|
||||||
|
an offer, in accord with Subsection b above.)
|
||||||
|
|
||||||
|
The source code for a work means the preferred form of the work for
|
||||||
|
making modifications to it. For an executable work, complete source
|
||||||
|
code means all the source code for all modules it contains, plus any
|
||||||
|
associated interface definition files, plus the scripts used to
|
||||||
|
control compilation and installation of the executable. However, as a
|
||||||
|
special exception, the source code distributed need not include
|
||||||
|
anything that is normally distributed (in either source or binary
|
||||||
|
form) with the major components (compiler, kernel, and so on) of the
|
||||||
|
operating system on which the executable runs, unless that component
|
||||||
|
itself accompanies the executable.
|
||||||
|
|
||||||
|
If distribution of executable or object code is made by offering
|
||||||
|
access to copy from a designated place, then offering equivalent
|
||||||
|
access to copy the source code from the same place counts as
|
||||||
|
distribution of the source code, even though third parties are not
|
||||||
|
compelled to copy the source along with the object code.
|
||||||
|
|
||||||
|
4. You may not copy, modify, sublicense, or distribute the Program
|
||||||
|
except as expressly provided under this License. Any attempt
|
||||||
|
otherwise to copy, modify, sublicense or distribute the Program is
|
||||||
|
void, and will automatically terminate your rights under this License.
|
||||||
|
However, parties who have received copies, or rights, from you under
|
||||||
|
this License will not have their licenses terminated so long as such
|
||||||
|
parties remain in full compliance.
|
||||||
|
|
||||||
|
5. You are not required to accept this License, since you have not
|
||||||
|
signed it. However, nothing else grants you permission to modify or
|
||||||
|
distribute the Program or its derivative works. These actions are
|
||||||
|
prohibited by law if you do not accept this License. Therefore, by
|
||||||
|
modifying or distributing the Program (or any work based on the
|
||||||
|
Program), you indicate your acceptance of this License to do so, and
|
||||||
|
all its terms and conditions for copying, distributing or modifying
|
||||||
|
the Program or works based on it.
|
||||||
|
|
||||||
|
6. Each time you redistribute the Program (or any work based on the
|
||||||
|
Program), the recipient automatically receives a license from the
|
||||||
|
original licensor to copy, distribute or modify the Program subject to
|
||||||
|
these terms and conditions. You may not impose any further
|
||||||
|
restrictions on the recipients' exercise of the rights granted herein.
|
||||||
|
You are not responsible for enforcing compliance by third parties to
|
||||||
|
this License.
|
||||||
|
|
||||||
|
7. If, as a consequence of a court judgment or allegation of patent
|
||||||
|
infringement or for any other reason (not limited to patent issues),
|
||||||
|
conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot
|
||||||
|
distribute so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you
|
||||||
|
may not distribute the Program at all. For example, if a patent
|
||||||
|
license would not permit royalty-free redistribution of the Program by
|
||||||
|
all those who receive copies directly or indirectly through you, then
|
||||||
|
the only way you could satisfy both it and this License would be to
|
||||||
|
refrain entirely from distribution of the Program.
|
||||||
|
|
||||||
|
If any portion of this section is held invalid or unenforceable under
|
||||||
|
any particular circumstance, the balance of the section is intended to
|
||||||
|
apply and the section as a whole is intended to apply in other
|
||||||
|
circumstances.
|
||||||
|
|
||||||
|
It is not the purpose of this section to induce you to infringe any
|
||||||
|
patents or other property right claims or to contest validity of any
|
||||||
|
such claims; this section has the sole purpose of protecting the
|
||||||
|
integrity of the free software distribution system, which is
|
||||||
|
implemented by public license practices. Many people have made
|
||||||
|
generous contributions to the wide range of software distributed
|
||||||
|
through that system in reliance on consistent application of that
|
||||||
|
system; it is up to the author/donor to decide if he or she is willing
|
||||||
|
to distribute software through any other system and a licensee cannot
|
||||||
|
impose that choice.
|
||||||
|
|
||||||
|
This section is intended to make thoroughly clear what is believed to
|
||||||
|
be a consequence of the rest of this License.
|
||||||
|
|
||||||
|
8. If the distribution and/or use of the Program is restricted in
|
||||||
|
certain countries either by patents or by copyrighted interfaces, the
|
||||||
|
original copyright holder who places the Program under this License
|
||||||
|
may add an explicit geographical distribution limitation excluding
|
||||||
|
those countries, so that distribution is permitted only in or among
|
||||||
|
countries not thus excluded. In such case, this License incorporates
|
||||||
|
the limitation as if written in the body of this License.
|
||||||
|
|
||||||
|
9. The Free Software Foundation may publish revised and/or new versions
|
||||||
|
of the General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the Program
|
||||||
|
specifies a version number of this License which applies to it and "any
|
||||||
|
later version", you have the option of following the terms and conditions
|
||||||
|
either of that version or of any later version published by the Free
|
||||||
|
Software Foundation. If the Program does not specify a version number of
|
||||||
|
this License, you may choose any version ever published by the Free Software
|
||||||
|
Foundation.
|
||||||
|
|
||||||
|
10. If you wish to incorporate parts of the Program into other free
|
||||||
|
programs whose distribution conditions are different, write to the author
|
||||||
|
to ask for permission. For software which is copyrighted by the Free
|
||||||
|
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||||
|
make exceptions for this. Our decision will be guided by the two goals
|
||||||
|
of preserving the free status of all derivatives of our free software and
|
||||||
|
of promoting the sharing and reuse of software generally.
|
||||||
|
|
||||||
|
NO WARRANTY
|
||||||
|
|
||||||
|
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||||
|
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||||
|
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||||
|
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||||
|
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||||
|
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||||
|
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||||
|
REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||||
|
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||||
|
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||||
|
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||||
|
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||||
|
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||||
|
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
convey the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along
|
||||||
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program is interactive, make it output a short notice like this
|
||||||
|
when it starts in an interactive mode:
|
||||||
|
|
||||||
|
Gnomovision version 69, Copyright (C) year name of author
|
||||||
|
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, the commands you use may
|
||||||
|
be called something other than `show w' and `show c'; they could even be
|
||||||
|
mouse-clicks or menu items--whatever suits your program.
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or your
|
||||||
|
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||||
|
necessary. Here is a sample; alter the names:
|
||||||
|
|
||||||
|
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||||
|
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||||
|
|
||||||
|
<signature of Ty Coon>, 1 April 1989
|
||||||
|
Ty Coon, President of Vice
|
||||||
|
|
||||||
|
This General Public License does not permit incorporating your program into
|
||||||
|
proprietary programs. If your program is a subroutine library, you may
|
||||||
|
consider it more useful to permit linking proprietary applications with the
|
||||||
|
library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License.
|
||||||
|
|
53
README.md
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
gedit
|
||||||
|
=====
|
||||||
|
|
||||||
|
gedit is an easy-to-use and general-purpose text editor. Its development started
|
||||||
|
in 1998, at the beginnings of the GNOME project, with a good integration with
|
||||||
|
that desktop environment.
|
||||||
|
|
||||||
|
You can use it to write simple notes and documents, or you can enable more
|
||||||
|
advanced features that are useful for software development.
|
||||||
|
|
||||||
|
See the [gedit website](https://gedit-technology.github.io/apps/gedit/) for more
|
||||||
|
information.
|
||||||
|
|
||||||
|
License
|
||||||
|
-------
|
||||||
|
|
||||||
|
gedit is released under the GNU General Public License (GPL) version 2 or
|
||||||
|
later, see the file [COPYING](COPYING) for more information.
|
||||||
|
|
||||||
|
Dependencies
|
||||||
|
------------
|
||||||
|
|
||||||
|
gedit depends on GTK 3 and
|
||||||
|
[Gedit Technology](https://gedit-technology.github.io/).
|
||||||
|
|
||||||
|
For a complete list of dependencies, see the [meson.build](meson.build) file.
|
||||||
|
|
||||||
|
Installation
|
||||||
|
------------
|
||||||
|
|
||||||
|
To build gedit from source, see the [docs/build.md](docs/build.md) file.
|
||||||
|
|
||||||
|
How to report bugs
|
||||||
|
------------------
|
||||||
|
|
||||||
|
Please read
|
||||||
|
[the web page on how to report bugs](https://gedit-technology.github.io/apps/gedit/reporting-bugs.html),
|
||||||
|
it contains a list of frequently reported bugs and a link to the bug
|
||||||
|
tracker.
|
||||||
|
|
||||||
|
Development resources
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
- [gedit projects on GitLab](https://gitlab.gnome.org/World/gedit)
|
||||||
|
- [Tarballs](https://download.gnome.org/sources/gedit/)
|
||||||
|
|
||||||
|
Contributions
|
||||||
|
-------------
|
||||||
|
|
||||||
|
gedit development relies on voluntary contributions and everyone is invited
|
||||||
|
to help.
|
||||||
|
|
||||||
|
See the [CONTRIBUTING.md](CONTRIBUTING.md) file for more information.
|
5
build-aux/buildstream/README.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
gedit BuildStream elements
|
||||||
|
==========================
|
||||||
|
|
||||||
|
Copy the `*.bst` files in gnome-build-meta's `elements/world/` directory, and
|
||||||
|
then run BuildStream as usual from there.
|
15
build-aux/buildstream/amtk.bst
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
kind: meson
|
||||||
|
|
||||||
|
sources:
|
||||||
|
- kind: git_tag
|
||||||
|
url: gnome_gitlab:World/amtk.git
|
||||||
|
track: master
|
||||||
|
|
||||||
|
build-depends:
|
||||||
|
- sdk/gobject-introspection.bst
|
||||||
|
- sdk/gtk-doc.bst
|
||||||
|
- freedesktop-sdk.bst:public-stacks/buildsystem-meson.bst
|
||||||
|
|
||||||
|
depends:
|
||||||
|
- sdk/gtk+-3.bst
|
||||||
|
- freedesktop-sdk.bst:bootstrap-import.bst
|
27
build-aux/buildstream/gedit.bst
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
kind: meson
|
||||||
|
|
||||||
|
sources:
|
||||||
|
- kind: git_tag
|
||||||
|
url: gnome:gedit.git
|
||||||
|
track: master
|
||||||
|
submodules:
|
||||||
|
subprojects/libgd:
|
||||||
|
checkout: true
|
||||||
|
url: gnome:libgd.git
|
||||||
|
|
||||||
|
build-depends:
|
||||||
|
- sdk/appstream-glib.bst
|
||||||
|
- sdk/gtk-doc.bst
|
||||||
|
- sdk/gobject-introspection.bst
|
||||||
|
- sdk/vala.bst
|
||||||
|
- freedesktop-sdk.bst:components/itstool.bst
|
||||||
|
- freedesktop-sdk.bst:components/perl.bst
|
||||||
|
- freedesktop-sdk.bst:public-stacks/buildsystem-meson.bst
|
||||||
|
|
||||||
|
depends:
|
||||||
|
- core-deps/gspell.bst
|
||||||
|
- core-deps/libpeas.bst
|
||||||
|
- sdk/adwaita-icon-theme.bst
|
||||||
|
- sdk/gsettings-desktop-schemas.bst
|
||||||
|
- world/tepl.bst
|
||||||
|
- freedesktop-sdk.bst:bootstrap-import.bst
|
18
build-aux/buildstream/tepl.bst
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
kind: meson
|
||||||
|
|
||||||
|
sources:
|
||||||
|
- kind: git_tag
|
||||||
|
url: gnome_gitlab:swilmet/tepl.git
|
||||||
|
track: main
|
||||||
|
|
||||||
|
build-depends:
|
||||||
|
- sdk/gobject-introspection.bst
|
||||||
|
- sdk/gtk-doc.bst
|
||||||
|
- freedesktop-sdk.bst:public-stacks/buildsystem-meson.bst
|
||||||
|
|
||||||
|
depends:
|
||||||
|
- sdk/gsettings-desktop-schemas.bst
|
||||||
|
- sdk/gtksourceview-4.bst
|
||||||
|
- world/amtk.bst
|
||||||
|
- freedesktop-sdk.bst:components/icu.bst
|
||||||
|
- freedesktop-sdk.bst:bootstrap-import.bst
|
2
build-aux/flatpak/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
.flatpak-builder/
|
||||||
|
build/
|
8
build-aux/flatpak/0-readme.md
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
gedit flatpak
|
||||||
|
=============
|
||||||
|
|
||||||
|
First, you need to set up gnome-nightly:
|
||||||
|
|
||||||
|
https://wiki.gnome.org/Apps/Nightly
|
||||||
|
|
||||||
|
And install its runtime and SDK.
|
3
build-aux/flatpak/1-build-and-install.sh
Executable file
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
flatpak-builder --force-clean --user --install build org.gnome.gedit.yml
|
3
build-aux/flatpak/2-run-app.sh
Executable file
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
flatpak run org.gnome.gedit
|
3
build-aux/flatpak/3-teardown.sh
Executable file
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
flatpak uninstall --user org.gnome.gedit
|
11
build-aux/flatpak/generate-json-manifest.sh
Executable file
|
@ -0,0 +1,11 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# SPDX-FileCopyrightText: Copyright 2022 Jake Dane
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
# yq: A portable command-line YAML processor.
|
||||||
|
# Currently hosted here: https://github.com/mikefarah/yq
|
||||||
|
|
||||||
|
# At the time of writing, some tools around Flatpak (for example gnome-builder)
|
||||||
|
# only supports the *.json format, but *.yml is easier to edit.
|
||||||
|
|
||||||
|
yq eval 'org.gnome.gedit.yml' --output-format json > 'org.gnome.gedit.json'
|
138
build-aux/flatpak/org.gnome.gedit.json
Normal file
|
@ -0,0 +1,138 @@
|
||||||
|
{
|
||||||
|
"app-id": "org.gnome.gedit",
|
||||||
|
"runtime": "org.gnome.Platform",
|
||||||
|
"runtime-version": "master",
|
||||||
|
"sdk": "org.gnome.Sdk",
|
||||||
|
"command": "gedit",
|
||||||
|
"tags": [
|
||||||
|
"nightly"
|
||||||
|
],
|
||||||
|
"desktop-file-name-prefix": "(Nightly) ",
|
||||||
|
"finish-args": [
|
||||||
|
"--share=ipc",
|
||||||
|
"--socket=x11",
|
||||||
|
"--socket=fallback-x11",
|
||||||
|
"--socket=wayland",
|
||||||
|
"--metadata=X-DConf=migrate-path=/org/gnome/gedit/",
|
||||||
|
"--filesystem=host",
|
||||||
|
"--filesystem=xdg-run/gvfsd",
|
||||||
|
"--talk-name=org.gtk.vfs.*"
|
||||||
|
],
|
||||||
|
"build-options": {
|
||||||
|
"cflags": "-O2 -g",
|
||||||
|
"cxxflags": "-O2 -g",
|
||||||
|
"env": {
|
||||||
|
"V": "1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"cleanup": [
|
||||||
|
"/include",
|
||||||
|
"/lib/pkgconfig",
|
||||||
|
"/share/pkgconfig",
|
||||||
|
"/share/aclocal",
|
||||||
|
"/man",
|
||||||
|
"/share/man",
|
||||||
|
"/share/gtk-doc",
|
||||||
|
"/share/vala",
|
||||||
|
"/share/gir-1.0",
|
||||||
|
"*.la",
|
||||||
|
"*.a"
|
||||||
|
],
|
||||||
|
"modules": [
|
||||||
|
{
|
||||||
|
"name": "libpeas",
|
||||||
|
"buildsystem": "meson",
|
||||||
|
"config-opts": [
|
||||||
|
"-Dlua51=false",
|
||||||
|
"-Dglade_catalog=false",
|
||||||
|
"-Ddemos=false"
|
||||||
|
],
|
||||||
|
"sources": [
|
||||||
|
{
|
||||||
|
"type": "archive",
|
||||||
|
"url": "https://download.gnome.org/sources/libpeas/1.36/libpeas-1.36.0.tar.xz",
|
||||||
|
"sha256": "297cb9c2cccd8e8617623d1a3e8415b4530b8e5a893e3527bbfd1edd13237b4c"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "gspell",
|
||||||
|
"cleanup": [
|
||||||
|
"/bin"
|
||||||
|
],
|
||||||
|
"sources": [
|
||||||
|
{
|
||||||
|
"type": "archive",
|
||||||
|
"url": "https://download.gnome.org/sources/gspell/1.12/gspell-1.12.2.tar.xz",
|
||||||
|
"sha256": "b4e993bd827e4ceb6a770b1b5e8950fce3be9c8b2b0cbeb22fdf992808dd2139"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "libgedit-amtk",
|
||||||
|
"buildsystem": "meson",
|
||||||
|
"config-opts": [
|
||||||
|
"-Dgtk_doc=false"
|
||||||
|
],
|
||||||
|
"sources": [
|
||||||
|
{
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/gedit-technology/libgedit-amtk.git",
|
||||||
|
"branch": "main"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "libgedit-gtksourceview",
|
||||||
|
"buildsystem": "meson",
|
||||||
|
"config-opts": [
|
||||||
|
"-Dgtk_doc=false",
|
||||||
|
"-Dtests_relying_on_external_programs=false"
|
||||||
|
],
|
||||||
|
"sources": [
|
||||||
|
{
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/gedit-technology/libgedit-gtksourceview.git",
|
||||||
|
"branch": "main"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "tepl",
|
||||||
|
"buildsystem": "meson",
|
||||||
|
"config-opts": [
|
||||||
|
"-Dgtk_doc=false"
|
||||||
|
],
|
||||||
|
"sources": [
|
||||||
|
{
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://gitlab.gnome.org/swilmet/tepl.git",
|
||||||
|
"branch": "main"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "gedit",
|
||||||
|
"buildsystem": "meson",
|
||||||
|
"config-opts": [
|
||||||
|
"-Dgtk_doc=false"
|
||||||
|
],
|
||||||
|
"sources": [
|
||||||
|
{
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://gitlab.gnome.org/GNOME/gedit.git"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "gedit-plugins",
|
||||||
|
"buildsystem": "meson",
|
||||||
|
"sources": [
|
||||||
|
{
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://gitlab.gnome.org/GNOME/gedit-plugins.git"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
108
build-aux/flatpak/org.gnome.gedit.yml
Normal file
|
@ -0,0 +1,108 @@
|
||||||
|
# After editing this file run generate-json-manifest.sh.
|
||||||
|
# Don't edit the *.json manifest file by hand.
|
||||||
|
---
|
||||||
|
app-id: org.gnome.gedit
|
||||||
|
runtime: org.gnome.Platform
|
||||||
|
runtime-version: master
|
||||||
|
sdk: org.gnome.Sdk
|
||||||
|
command: gedit
|
||||||
|
tags:
|
||||||
|
- nightly
|
||||||
|
desktop-file-name-prefix: "(Nightly) "
|
||||||
|
|
||||||
|
finish-args:
|
||||||
|
- "--share=ipc"
|
||||||
|
- "--socket=x11"
|
||||||
|
- "--socket=fallback-x11"
|
||||||
|
- "--socket=wayland"
|
||||||
|
- "--metadata=X-DConf=migrate-path=/org/gnome/gedit/"
|
||||||
|
# Needed at least for the integrated file browser plugin:
|
||||||
|
- "--filesystem=host"
|
||||||
|
# GVfs GIO APIs access using backend URIs
|
||||||
|
- "--filesystem=xdg-run/gvfsd"
|
||||||
|
# For opening files from remote locations (with GVfs):
|
||||||
|
- "--talk-name=org.gtk.vfs.*"
|
||||||
|
|
||||||
|
build-options:
|
||||||
|
cflags: "-O2 -g"
|
||||||
|
cxxflags: "-O2 -g"
|
||||||
|
env:
|
||||||
|
V: '1'
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
- "/include"
|
||||||
|
- "/lib/pkgconfig"
|
||||||
|
- "/share/pkgconfig"
|
||||||
|
- "/share/aclocal"
|
||||||
|
- "/man"
|
||||||
|
- "/share/man"
|
||||||
|
- "/share/gtk-doc"
|
||||||
|
- "/share/vala"
|
||||||
|
- "/share/gir-1.0"
|
||||||
|
- "*.la"
|
||||||
|
- "*.a"
|
||||||
|
|
||||||
|
modules:
|
||||||
|
- name: libpeas
|
||||||
|
buildsystem: meson
|
||||||
|
config-opts:
|
||||||
|
- "-Dlua51=false"
|
||||||
|
- "-Dglade_catalog=false"
|
||||||
|
- "-Ddemos=false"
|
||||||
|
sources:
|
||||||
|
- type: archive
|
||||||
|
url: https://download.gnome.org/sources/libpeas/1.36/libpeas-1.36.0.tar.xz
|
||||||
|
sha256: 297cb9c2cccd8e8617623d1a3e8415b4530b8e5a893e3527bbfd1edd13237b4c
|
||||||
|
|
||||||
|
- name: gspell
|
||||||
|
cleanup:
|
||||||
|
- "/bin"
|
||||||
|
sources:
|
||||||
|
- type: archive
|
||||||
|
url: https://download.gnome.org/sources/gspell/1.12/gspell-1.12.2.tar.xz
|
||||||
|
sha256: b4e993bd827e4ceb6a770b1b5e8950fce3be9c8b2b0cbeb22fdf992808dd2139
|
||||||
|
|
||||||
|
- name: libgedit-amtk
|
||||||
|
buildsystem: meson
|
||||||
|
config-opts:
|
||||||
|
- "-Dgtk_doc=false"
|
||||||
|
sources:
|
||||||
|
- type: git
|
||||||
|
url: https://github.com/gedit-technology/libgedit-amtk.git
|
||||||
|
branch: main
|
||||||
|
|
||||||
|
- name: libgedit-gtksourceview
|
||||||
|
buildsystem: meson
|
||||||
|
config-opts:
|
||||||
|
- "-Dgtk_doc=false"
|
||||||
|
- "-Dtests_relying_on_external_programs=false"
|
||||||
|
sources:
|
||||||
|
- type: git
|
||||||
|
url: https://github.com/gedit-technology/libgedit-gtksourceview.git
|
||||||
|
branch: main
|
||||||
|
|
||||||
|
- name: tepl
|
||||||
|
buildsystem: meson
|
||||||
|
config-opts:
|
||||||
|
- "-Dgtk_doc=false"
|
||||||
|
sources:
|
||||||
|
- type: git
|
||||||
|
url: https://gitlab.gnome.org/swilmet/tepl.git
|
||||||
|
branch: main
|
||||||
|
|
||||||
|
- name: gedit
|
||||||
|
buildsystem: meson
|
||||||
|
config-opts:
|
||||||
|
- "-Dgtk_doc=false"
|
||||||
|
sources:
|
||||||
|
- type: git
|
||||||
|
url: https://gitlab.gnome.org/GNOME/gedit.git
|
||||||
|
# To build a local branch, comment out 'url' and uncomment:
|
||||||
|
# path: ../../
|
||||||
|
# branch: wip/misc
|
||||||
|
|
||||||
|
- name: gedit-plugins
|
||||||
|
buildsystem: meson
|
||||||
|
sources:
|
||||||
|
- type: git
|
||||||
|
url: https://gitlab.gnome.org/GNOME/gedit-plugins.git
|
17
build-aux/meson/post_install.py
Executable file
|
@ -0,0 +1,17 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
|
libdir = sys.argv[1]
|
||||||
|
|
||||||
|
# Packaging tools define DESTDIR and this isn't needed for them
|
||||||
|
if 'DESTDIR' not in os.environ:
|
||||||
|
print('Compiling python modules...')
|
||||||
|
subprocess.call([sys.executable, '-m', 'compileall', '-f', '-q',
|
||||||
|
os.path.join(libdir, 'gedit', 'plugins')])
|
||||||
|
|
||||||
|
print('Compiling python modules (optimized versions) ...')
|
||||||
|
subprocess.call([sys.executable, '-O', '-m', 'compileall', '-f', '-q',
|
||||||
|
os.path.join(libdir, 'gedit', 'plugins')])
|
192
build-aux/snap/snapcraft.yaml
Normal file
|
@ -0,0 +1,192 @@
|
||||||
|
name: gedit
|
||||||
|
version: git
|
||||||
|
adopt-info: gedit
|
||||||
|
grade: stable # must be 'stable' to release into candidate/stable channels
|
||||||
|
confinement: strict
|
||||||
|
base: core18
|
||||||
|
|
||||||
|
layout:
|
||||||
|
/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libpeas-1.0:
|
||||||
|
symlink: $SNAP/gnome-platform/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/libpeas-1.0
|
||||||
|
/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/gedit:
|
||||||
|
symlink: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/gedit
|
||||||
|
/usr/share/gedit:
|
||||||
|
symlink: $SNAP/usr/share/gedit
|
||||||
|
|
||||||
|
slots:
|
||||||
|
# for GtkApplication registration
|
||||||
|
gedit:
|
||||||
|
interface: dbus
|
||||||
|
bus: session
|
||||||
|
name: org.gnome.gedit
|
||||||
|
|
||||||
|
apps:
|
||||||
|
gedit:
|
||||||
|
command: usr/bin/gedit
|
||||||
|
extensions: [gnome-3-28]
|
||||||
|
plugs:
|
||||||
|
- avahi-observe
|
||||||
|
- cups-control
|
||||||
|
- gsettings
|
||||||
|
- home
|
||||||
|
- network
|
||||||
|
- mount-observe
|
||||||
|
- removable-media
|
||||||
|
common-id: org.gnome.gedit.desktop
|
||||||
|
environment:
|
||||||
|
GSETTINGS_SCHEMA_DIR: $SNAP/share/glib-2.0/schemas
|
||||||
|
LD_LIBRARY_PATH: $LD_LIBRARY_PATH:$SNAP/lib/$SNAPCRAFT_ARCH_TRIPLET/gedit:$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET:$SNAP/gnome-platform/usr/lib/$SNAPCRAFT_ARCH_TRIPLET
|
||||||
|
GI_TYPELIB_PATH: $SNAP/usr/lib/girepository-1.0:$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/gedit/girepository-1.0:$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/girepository-1.0:$SNAP/gnome-platform/usr/lib/girepository-1.0:$SNAP/gnome-platform/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/girepository-1.0
|
||||||
|
PYTHONPATH: $SNAP/usr/lib/python3/dist-packages:$SNAP/gnome-platform/usr/lib/python3/dist-packages
|
||||||
|
GTK_USE_PORTAL: 1
|
||||||
|
|
||||||
|
parts:
|
||||||
|
amtk:
|
||||||
|
source: https://gitlab.gnome.org/GNOME/amtk.git
|
||||||
|
source-type: git
|
||||||
|
plugin: autotools
|
||||||
|
configflags:
|
||||||
|
- --prefix=/usr
|
||||||
|
- --enable-introspection=no
|
||||||
|
organize:
|
||||||
|
snap/gedit/current/usr: usr
|
||||||
|
|
||||||
|
tepl:
|
||||||
|
after: [amtk, gtksourceview]
|
||||||
|
source: https://gitlab.gnome.org/GNOME/tepl.git
|
||||||
|
source-type: git
|
||||||
|
plugin: meson
|
||||||
|
meson-parameters:
|
||||||
|
- --prefix=/usr
|
||||||
|
organize:
|
||||||
|
snap/gedit/current/usr: usr
|
||||||
|
build-packages:
|
||||||
|
- libuchardet-dev
|
||||||
|
stage-packages:
|
||||||
|
- libuchardet0
|
||||||
|
|
||||||
|
gtksourceview:
|
||||||
|
source: https://gitlab.gnome.org/GNOME/gtksourceview.git
|
||||||
|
source-type: git
|
||||||
|
plugin: meson
|
||||||
|
meson-parameters:
|
||||||
|
- --prefix=/usr
|
||||||
|
- -Dc_args="-Wno-error=undef"
|
||||||
|
organize:
|
||||||
|
snap/gedit/current/usr: usr
|
||||||
|
build-packages:
|
||||||
|
- autoconf-archive
|
||||||
|
- gettext
|
||||||
|
- gobject-introspection
|
||||||
|
- gtk-doc-tools
|
||||||
|
- libfribidi-dev
|
||||||
|
- libgirepository1.0-dev
|
||||||
|
- libglib2.0-dev
|
||||||
|
- libgtk-3-dev
|
||||||
|
- libpeas-dev
|
||||||
|
- libxml2-dev
|
||||||
|
- libxml2-utils
|
||||||
|
- valac
|
||||||
|
# meson gir overrides don't work well
|
||||||
|
override-build: |
|
||||||
|
snapcraftctl build
|
||||||
|
cp $SNAPCRAFT_PART_INSTALL/usr/share/gir-1.0/GtkSource* /usr/share/gir-1.0
|
||||||
|
cp $SNAPCRAFT_PART_INSTALL/usr/share/vala/vapi/gtksource* /usr/share/vala/vapi
|
||||||
|
|
||||||
|
gedit:
|
||||||
|
after: [gtksourceview, tepl]
|
||||||
|
source: .
|
||||||
|
source-type: git
|
||||||
|
parse-info: [usr/share/metainfo/org.gnome.gedit.appdata.xml]
|
||||||
|
plugin: meson
|
||||||
|
meson-parameters:
|
||||||
|
- --prefix=/usr
|
||||||
|
- -Dvala_args="--vapidir=$SNAPCRAFT_STAGE/usr/share/vala/vapi"
|
||||||
|
build-environment:
|
||||||
|
- C_INCLUDE_PATH: $SNAPCRAFT_STAGE/usr/include/gtksourceview-4
|
||||||
|
override-build: |
|
||||||
|
sed -i.bak -e 's|Icon=org.gnome.gedit$|Icon=${SNAP}/meta/gui/org.gnome.gedit.svg|g' data/org.gnome.gedit.desktop.in
|
||||||
|
sed -i.bak -e "s|symlink_media: true|symlink_media: false|g" help/meson.build
|
||||||
|
snapcraftctl build
|
||||||
|
mkdir -p $SNAPCRAFT_PART_INSTALL/meta/gui/
|
||||||
|
cp data/icons/org.gnome.gedit.svg $SNAPCRAFT_PART_INSTALL/meta/gui/
|
||||||
|
cp ../install/usr/share/applications/org.gnome.gedit.desktop $SNAPCRAFT_PART_INSTALL/meta/gui/
|
||||||
|
build-packages:
|
||||||
|
- desktop-file-utils
|
||||||
|
- gettext
|
||||||
|
- gsettings-desktop-schemas-dev
|
||||||
|
- gtk-doc-tools
|
||||||
|
- itstool
|
||||||
|
- libsoup2.4-dev
|
||||||
|
- libgspell-1-dev
|
||||||
|
- libxml2-dev
|
||||||
|
- libglib2.0-dev
|
||||||
|
- libgtk-3-dev
|
||||||
|
- libpeas-dev
|
||||||
|
- libx11-dev
|
||||||
|
- python3
|
||||||
|
- python-gi-dev
|
||||||
|
- gobject-introspection
|
||||||
|
- libgirepository1.0-dev
|
||||||
|
- valac
|
||||||
|
stage-packages:
|
||||||
|
- libfribidi0
|
||||||
|
|
||||||
|
gedit-plugins:
|
||||||
|
after: [gedit]
|
||||||
|
source: https://gitlab.gnome.org/GNOME/gedit-plugins.git
|
||||||
|
source-type: git
|
||||||
|
plugin: meson
|
||||||
|
meson-parameters:
|
||||||
|
- --prefix=/snap/gedit/current/usr
|
||||||
|
- -Dplugin_bookmarks=true
|
||||||
|
- -Dplugin_bracketcompletion=true
|
||||||
|
- -Dplugin_charmap=true
|
||||||
|
- -Dplugin_codecomment=true
|
||||||
|
- -Dplugin_colorpicker=true
|
||||||
|
- -Dplugin_colorschemer=true
|
||||||
|
- -Dplugin_commander=false
|
||||||
|
- -Dplugin_drawspaces=true
|
||||||
|
- -Dplugin_findinfiles=false
|
||||||
|
- -Dplugin_git=true
|
||||||
|
- -Dplugin_joinlines=true
|
||||||
|
- -Dplugin_multiedit=false
|
||||||
|
- -Dplugin_smartspaces=true
|
||||||
|
- -Dplugin_terminal=true
|
||||||
|
- -Dplugin_textsize=true
|
||||||
|
- -Dplugin_translate=true
|
||||||
|
- -Dplugin_wordcompletion=true
|
||||||
|
- -Dplugin_zeitgeist=false
|
||||||
|
organize:
|
||||||
|
snap/gedit/current/usr: usr
|
||||||
|
build-environment:
|
||||||
|
- C_INCLUDE_PATH: $SNAPCRAFT_STAGE/usr/include:$SNAPCRAFT_STAGE/usr/include/gedit-3.14:$SNAPCRAFT_STAGE/usr/include/gtksourceview-4
|
||||||
|
- LD_LIBRARY_PATH: $LD_LIBRARY_PATH:$SNAPCRAFT_STAGE/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/gedit
|
||||||
|
- PKG_CONFIG_PATH: $PKG_CONFIG_PATH:$SNAPCRAFT_STAGE/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/pkgconfig
|
||||||
|
build-packages:
|
||||||
|
- appstream
|
||||||
|
- build-essential
|
||||||
|
- gettext
|
||||||
|
- gnome-common
|
||||||
|
- itstool
|
||||||
|
- libgit2-glib-1.0-dev
|
||||||
|
- libglib2.0-dev
|
||||||
|
- libgtk-3-dev
|
||||||
|
- libgucharmap-2-90-dev
|
||||||
|
- libvte-2.91-dev
|
||||||
|
- python3
|
||||||
|
- python3-dbus
|
||||||
|
- python-dbus-dev
|
||||||
|
- python-gi-dev
|
||||||
|
- yelp-tools
|
||||||
|
stage-packages:
|
||||||
|
- python3
|
||||||
|
- python3-dbus
|
||||||
|
- python3-gi
|
||||||
|
- python3-setuptools
|
||||||
|
# Zeitgeist plugin isn't as useful in a Snap.
|
||||||
|
stage:
|
||||||
|
- -usr/lib/gedit/plugins/libzeitgeist.so
|
||||||
|
- -usr/lib/gedit/plugins/zeitgeist.plugin
|
||||||
|
- -usr/share/help/*/gedit/zeitgeist-dataprovider.page
|
||||||
|
- -usr/share/metainfo/gedit-zeitgeist.metainfo.xml
|
1
build/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
*
|
5
data/gedit-osx.gschema.override
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
[org.gnome.desktop.interface]
|
||||||
|
monospace-font-name = 'Menlo 12'
|
||||||
|
|
||||||
|
[org.gnome.gedit.preferences.editor]
|
||||||
|
editor-font = 'Menlo 12'
|
96
data/gedit.1
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
.TH GEDIT 1 "17 July 2022"
|
||||||
|
.SH NAME
|
||||||
|
\fBgedit\fP \- a general-purpose text editor
|
||||||
|
|
||||||
|
.SH SYNOPSIS
|
||||||
|
.br
|
||||||
|
.B gedit
|
||||||
|
[\fIOPTION\fR...] [\fIFILE\fR...] [+\fILINE\fR[:\fICOLUMN\fR]]
|
||||||
|
.br
|
||||||
|
.B gedit
|
||||||
|
[\fIOPTION\fR...] -
|
||||||
|
|
||||||
|
.SH DESCRIPTION
|
||||||
|
.B gedit
|
||||||
|
is an easy-to-use and general-purpose text editor. Its development started
|
||||||
|
in 1998, at the beginnings of the GNOME project, with a good integration with
|
||||||
|
that desktop environment.
|
||||||
|
|
||||||
|
You can use it to write simple notes and documents, or you can enable more
|
||||||
|
advanced features that are useful for software development.
|
||||||
|
|
||||||
|
.LP
|
||||||
|
.SH OPTIONS
|
||||||
|
|
||||||
|
.TP
|
||||||
|
\fB\-\-encoding\fR
|
||||||
|
Set the character encoding to be used for opening the files listed on the command line.
|
||||||
|
.TP
|
||||||
|
\fB\-\-list-encodings\fR
|
||||||
|
Display list of possible values for the encoding option and exit.
|
||||||
|
.TP
|
||||||
|
\fB\-\-new\-window\fR
|
||||||
|
Create a new toplevel window in an existing instance of
|
||||||
|
.B gedit.
|
||||||
|
.TP
|
||||||
|
\fB\-\-new\-document\fR
|
||||||
|
Create a new document in an existing instance of
|
||||||
|
.B gedit.
|
||||||
|
.TP
|
||||||
|
\fB\-s, \-\-standalone\fR
|
||||||
|
Run
|
||||||
|
.B gedit
|
||||||
|
in standalone mode.
|
||||||
|
.TP
|
||||||
|
\fB\-w, \-\-wait\fR
|
||||||
|
Open files and block the
|
||||||
|
.B gedit
|
||||||
|
process.
|
||||||
|
.TP
|
||||||
|
\fB\-\-help\fR
|
||||||
|
Prints the command line options.
|
||||||
|
.TP
|
||||||
|
\fB\-\-version\fR
|
||||||
|
Output version information and exit.
|
||||||
|
.TP
|
||||||
|
\fBFILE\fR
|
||||||
|
Specifies the file to open when
|
||||||
|
.B gedit
|
||||||
|
starts. If this is not specified,
|
||||||
|
.B gedit
|
||||||
|
will load a blank file with an "Unsaved Document" label. Multiple files can be loaded if they are
|
||||||
|
separated by spaces.
|
||||||
|
.B gedit
|
||||||
|
also supports handling of remote files. For example, you can pass the location
|
||||||
|
of a webpage to
|
||||||
|
.B gedit
|
||||||
|
, like "http://www.gnome.org", or load a file from a FTP server,
|
||||||
|
like "ftp://ftp.gnome.org/robots.txt".
|
||||||
|
.TP
|
||||||
|
\fB-\fR
|
||||||
|
.B gedit will read from stdin
|
||||||
|
.TP
|
||||||
|
\fB+LINE\fR
|
||||||
|
For the first file, go to the line specified by LINE (do not insert a space between the "+" sign and the number).
|
||||||
|
If LINE is missing, go to the last line.
|
||||||
|
.TP
|
||||||
|
\fBCOLUMN\fR
|
||||||
|
For the first file, go to the column specified by COLUMN.
|
||||||
|
If COLUMN is missing, go to the first column.
|
||||||
|
|
||||||
|
.SH BUGS
|
||||||
|
If you find a bug, please report it at the GNOME bug tracker. See: https://gedit-technology.github.io/apps/gedit/reporting-bugs.html
|
||||||
|
.SH AUTHORS
|
||||||
|
.\" Top 5 authors (to not have a too long list), by relative contribution
|
||||||
|
.\" (number of commits at the time of writing).
|
||||||
|
Paolo Borelli
|
||||||
|
.br
|
||||||
|
Sébastien Wilmet
|
||||||
|
.br
|
||||||
|
Ignacio Casal Quinteiro
|
||||||
|
.br
|
||||||
|
Jesse van den Kieboom
|
||||||
|
.br
|
||||||
|
Paolo Maggi
|
||||||
|
.br
|
||||||
|
and many others.
|
40
data/icons/meson.build
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
install_data(
|
||||||
|
'org.gnome.gedit-16x16.png',
|
||||||
|
rename: ['org.gnome.gedit.png'],
|
||||||
|
install_dir: get_option('datadir') / 'icons/hicolor/16x16/apps'
|
||||||
|
)
|
||||||
|
|
||||||
|
install_data(
|
||||||
|
'org.gnome.gedit-22x22.png',
|
||||||
|
rename: ['org.gnome.gedit.png'],
|
||||||
|
install_dir: get_option('datadir') / 'icons/hicolor/22x22/apps'
|
||||||
|
)
|
||||||
|
|
||||||
|
install_data(
|
||||||
|
'org.gnome.gedit-24x24.png',
|
||||||
|
rename: ['org.gnome.gedit.png'],
|
||||||
|
install_dir: get_option('datadir') / 'icons/hicolor/24x24/apps'
|
||||||
|
)
|
||||||
|
|
||||||
|
install_data(
|
||||||
|
'org.gnome.gedit-32x32.png',
|
||||||
|
rename: ['org.gnome.gedit.png'],
|
||||||
|
install_dir: get_option('datadir') / 'icons/hicolor/32x32/apps'
|
||||||
|
)
|
||||||
|
|
||||||
|
install_data(
|
||||||
|
'org.gnome.gedit-48x48.png',
|
||||||
|
rename: ['org.gnome.gedit.png'],
|
||||||
|
install_dir: get_option('datadir') / 'icons/hicolor/48x48/apps'
|
||||||
|
)
|
||||||
|
|
||||||
|
install_data(
|
||||||
|
'org.gnome.gedit-256x256.png',
|
||||||
|
rename: ['org.gnome.gedit.png'],
|
||||||
|
install_dir: get_option('datadir') / 'icons/hicolor/256x256/apps'
|
||||||
|
)
|
||||||
|
|
||||||
|
install_data(
|
||||||
|
'org.gnome.gedit-symbolic.svg',
|
||||||
|
install_dir: get_option('datadir') / 'icons/hicolor/symbolic/apps'
|
||||||
|
)
|
BIN
data/icons/org.gnome.gedit-16x16.png
Normal file
After Width: | Height: | Size: 912 B |
BIN
data/icons/org.gnome.gedit-22x22.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
data/icons/org.gnome.gedit-24x24.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
data/icons/org.gnome.gedit-256x256.png
Normal file
After Width: | Height: | Size: 43 KiB |
BIN
data/icons/org.gnome.gedit-32x32.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
data/icons/org.gnome.gedit-48x48.png
Normal file
After Width: | Height: | Size: 2.7 KiB |
1
data/icons/org.gnome.gedit-symbolic.svg
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16.007"><g color="#000" font-weight="400" fill="#474747"><path d="M5.5 6.007a.5.5 0 100 1h6a.5.5 0 100-1zm0 2a.5.5 0 100 1h5a.5.5 0 100-1zm0 2a.5.5 0 100 1h6a.5.5 0 100-1zm0 2a.5.5 0 100 1h3a.5.5 0 100-1z" style="line-height:normal;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000;text-transform:none;text-orientation:mixed;shape-padding:0;isolation:auto;mix-blend-mode:normal" font-family="sans-serif" overflow="visible"/><path d="M4 1.007c-1.09 0-2 .91-2 2v11c0 1.09.91 2 2 2h9c1.09 0 2-.91 2-2v-11c0-1.09-.91-2-2-2v13H4v-13z" style="line-height:normal;-inkscape-font-specification:Sans;text-indent:0;text-align:start;text-decoration-line:none;text-transform:none;marker:none" font-family="Sans" overflow="visible"/><path d="M5.492 0A.5.5 0 005 .506v3a.5.5 0 101 0v-3A.5.5 0 005.492 0zm2 0A.5.5 0 007 .506v3a.5.5 0 101 0v-3A.5.5 0 007.492 0zm2 0A.5.5 0 009 .506v3a.5.5 0 101 0v-3A.5.5 0 009.492 0zm2 0A.5.5 0 0011 .506v3a.5.5 0 101 0v-3A.5.5 0 0011.492 0z" style="line-height:normal;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000;text-transform:none;text-orientation:mixed;shape-padding:0;isolation:auto;mix-blend-mode:normal" font-family="sans-serif" overflow="visible"/></g></svg>
|
After Width: | Height: | Size: 1.7 KiB |
95
data/meson.build
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
subdir('icons')
|
||||||
|
|
||||||
|
# Man page
|
||||||
|
|
||||||
|
install_man('gedit.1')
|
||||||
|
|
||||||
|
# AppStream metainfo
|
||||||
|
|
||||||
|
metainfo = 'org.gnome.gedit.metainfo.xml'
|
||||||
|
metainfo_file = i18n.merge_file(
|
||||||
|
input: metainfo + '.in',
|
||||||
|
output: metainfo,
|
||||||
|
po_dir: '../po/',
|
||||||
|
install: true,
|
||||||
|
install_dir: get_option('datadir') / 'metainfo'
|
||||||
|
)
|
||||||
|
|
||||||
|
appstreamcli = find_program('appstreamcli', required: get_option('require_all_tests'))
|
||||||
|
if appstreamcli.found()
|
||||||
|
test(
|
||||||
|
'validate-metainfo',
|
||||||
|
appstreamcli,
|
||||||
|
args: ['validate', '--no-net', metainfo_file]
|
||||||
|
)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Desktop file
|
||||||
|
|
||||||
|
desktop_file = 'org.gnome.gedit.desktop'
|
||||||
|
desktop_output_file = i18n.merge_file(
|
||||||
|
type: 'desktop',
|
||||||
|
input: desktop_file + '.in',
|
||||||
|
output: desktop_file,
|
||||||
|
po_dir: '../po/',
|
||||||
|
install: true,
|
||||||
|
install_dir: get_option('datadir') / 'applications'
|
||||||
|
)
|
||||||
|
|
||||||
|
desktop_file_validate = find_program('desktop-file-validate', required: get_option('require_all_tests'))
|
||||||
|
if desktop_file_validate.found()
|
||||||
|
test(
|
||||||
|
'validate-desktop',
|
||||||
|
desktop_file_validate,
|
||||||
|
args: [desktop_output_file]
|
||||||
|
)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# GSettings schema
|
||||||
|
|
||||||
|
gschema_config_data = configuration_data()
|
||||||
|
gschema_config_data.set(
|
||||||
|
'ACTIVE_PLUGINS',
|
||||||
|
'\'filebrowser\', \'sort\', \'spell\', \'textsize\''
|
||||||
|
)
|
||||||
|
|
||||||
|
gschema_file = configure_file(
|
||||||
|
input: 'org.gnome.gedit.gschema.xml.in',
|
||||||
|
output: 'org.gnome.gedit.gschema.xml',
|
||||||
|
configuration: gschema_config_data,
|
||||||
|
install_dir: get_option('datadir') / 'glib-2.0/schemas'
|
||||||
|
)
|
||||||
|
|
||||||
|
gschema_dtd = gio_dep.get_variable(pkgconfig: 'schemasdir') / 'gschema.dtd'
|
||||||
|
|
||||||
|
xmllint = find_program('xmllint', required: get_option('require_all_tests'))
|
||||||
|
if xmllint.found()
|
||||||
|
test(
|
||||||
|
'validate-gschema',
|
||||||
|
xmllint,
|
||||||
|
args: [
|
||||||
|
'--noout',
|
||||||
|
'--dtdvalid', gschema_dtd,
|
||||||
|
gschema_file,
|
||||||
|
]
|
||||||
|
)
|
||||||
|
endif
|
||||||
|
|
||||||
|
if host_machine.system() == 'windows'
|
||||||
|
install_data(
|
||||||
|
'org.gnome.gedit-ms-windows.gschema.override',
|
||||||
|
install_dir: get_option('datadir') / 'glib-2.0/schemas'
|
||||||
|
)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# D-Bus service
|
||||||
|
|
||||||
|
service_config_data = configuration_data()
|
||||||
|
service_config_data.set('bindir', get_option('prefix') / get_option('bindir'))
|
||||||
|
|
||||||
|
configure_file(
|
||||||
|
input: 'org.gnome.gedit.service.in',
|
||||||
|
output: 'org.gnome.gedit.service',
|
||||||
|
configuration: service_config_data,
|
||||||
|
install_dir: get_option('datadir') / 'dbus-1/services'
|
||||||
|
)
|
5
data/org.gnome.gedit-ms-windows.gschema.override
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
[org.gnome.desktop.interface]
|
||||||
|
monospace-font-name = 'Monospace 11'
|
||||||
|
|
||||||
|
[org.gnome.gedit.preferences.editor]
|
||||||
|
editor-font = 'Monospace 11'
|
23
data/org.gnome.gedit.desktop.in
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
[Desktop Entry]
|
||||||
|
Name=gedit
|
||||||
|
Comment=Edit text files
|
||||||
|
Exec=gedit %U
|
||||||
|
Terminal=false
|
||||||
|
Type=Application
|
||||||
|
StartupNotify=true
|
||||||
|
MimeType=text/plain;application/x-zerosize;
|
||||||
|
Icon=org.gnome.gedit
|
||||||
|
Categories=GNOME;GTK;Utility;TextEditor;
|
||||||
|
Actions=new-window;new-document;
|
||||||
|
# Translators: Do NOT translate or localize the semicolons. The list MUST also
|
||||||
|
# end with a semicolon. It contains search terms to find this application.
|
||||||
|
Keywords=Text;Editor;Plaintext;Write;gedit;
|
||||||
|
DBusActivatable=true
|
||||||
|
|
||||||
|
[Desktop Action new-window]
|
||||||
|
Name=New Window
|
||||||
|
Exec=gedit --new-window
|
||||||
|
|
||||||
|
[Desktop Action new-document]
|
||||||
|
Name=New Document
|
||||||
|
Exec=gedit --new-document
|
324
data/org.gnome.gedit.gschema.xml.in
Normal file
|
@ -0,0 +1,324 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<schemalist gettext-domain="gedit">
|
||||||
|
<enum id="org.gnome.gedit.WrapMode">
|
||||||
|
<value nick="none" value="0"/>
|
||||||
|
<value nick="char" value="1"/>
|
||||||
|
<value nick="word" value="2"/>
|
||||||
|
<value nick="word-char" value="3"/>
|
||||||
|
</enum>
|
||||||
|
|
||||||
|
<enum id="org.gnome.gedit.SmartHomeEnd">
|
||||||
|
<value nick="disabled" value="0"/>
|
||||||
|
<value nick="before" value="1"/>
|
||||||
|
<value nick="after" value="2"/>
|
||||||
|
<value nick="always" value="3"/>
|
||||||
|
</enum>
|
||||||
|
|
||||||
|
<enum id="org.gnome.gedit.ThemeVariant">
|
||||||
|
<value nick="system" value="0"/>
|
||||||
|
<value nick="light" value="1"/>
|
||||||
|
<value nick="dark" value="2"/>
|
||||||
|
</enum>
|
||||||
|
|
||||||
|
<schema id="org.gnome.gedit" path="/org/gnome/gedit/">
|
||||||
|
<child name="preferences" schema="org.gnome.gedit.preferences"/>
|
||||||
|
<child name="state" schema="org.gnome.gedit.state"/>
|
||||||
|
<child name="plugins" schema="org.gnome.gedit.plugins"/>
|
||||||
|
</schema>
|
||||||
|
<schema id="org.gnome.gedit.preferences" path="/org/gnome/gedit/preferences/">
|
||||||
|
<child name="editor" schema="org.gnome.gedit.preferences.editor"/>
|
||||||
|
<child name="ui" schema="org.gnome.gedit.preferences.ui"/>
|
||||||
|
<child name="print" schema="org.gnome.gedit.preferences.print"/>
|
||||||
|
<child name="encodings" schema="org.gnome.gedit.preferences.encodings"/>
|
||||||
|
</schema>
|
||||||
|
<schema id="org.gnome.gedit.preferences.editor" path="/org/gnome/gedit/preferences/editor/">
|
||||||
|
<key name="use-default-font" type="b">
|
||||||
|
<default>true</default>
|
||||||
|
<summary>Use Default Font</summary>
|
||||||
|
<description>Whether to use the system’s default fixed width font for editing text instead of a font specific to gedit. If this option is turned off, then the font named in the “Editor Font” option will be used instead of the system font.</description>
|
||||||
|
</key>
|
||||||
|
<key name="editor-font" type="s">
|
||||||
|
<!-- Translators: This is a GSettings default value. Do NOT change or localize the quotation marks! -->
|
||||||
|
<default l10n="messages">'Monospace 12'</default>
|
||||||
|
<summary>Editor Font</summary>
|
||||||
|
<description>A custom font that will be used for the editing area. This will only take effect if the “Use Default Font” option is turned off.</description>
|
||||||
|
</key>
|
||||||
|
<key name="style-scheme-for-light-theme-variant" type="s">
|
||||||
|
<default>'tango'</default>
|
||||||
|
<summary>Style Scheme for Light Theme Variant</summary>
|
||||||
|
<description>The ID of a libgedit-gtksourceview style scheme used to color the main text area when the application has a light theme applied.</description>
|
||||||
|
</key>
|
||||||
|
<key name="style-scheme-for-dark-theme-variant" type="s">
|
||||||
|
<default>'solarized-dark'</default>
|
||||||
|
<summary>Style Scheme for Dark Theme Variant</summary>
|
||||||
|
<description>The ID of a libgedit-gtksourceview style scheme used to color the main text area when the application has a dark theme applied.</description>
|
||||||
|
</key>
|
||||||
|
<key name="create-backup-copy" type="b">
|
||||||
|
<default>false</default>
|
||||||
|
<summary>Create Backup Copies</summary>
|
||||||
|
<description>Whether gedit should create backup copies for the files it saves.</description>
|
||||||
|
</key>
|
||||||
|
<key name="auto-save" type="b">
|
||||||
|
<default>false</default>
|
||||||
|
<summary>Autosave</summary>
|
||||||
|
<description>Whether gedit should automatically save modified files after a time interval. You can set the time interval with the “Autosave Interval” option.</description>
|
||||||
|
</key>
|
||||||
|
<key name="auto-save-interval" type="u">
|
||||||
|
<range min="1" max="100"/>
|
||||||
|
<default>10</default>
|
||||||
|
<summary>Autosave Interval</summary>
|
||||||
|
<description>Number of minutes after which gedit will automatically save modified files. This will only take effect if the “Autosave” option is turned on.</description>
|
||||||
|
</key>
|
||||||
|
<key name="max-undo-actions" type="i">
|
||||||
|
<default>2000</default>
|
||||||
|
<summary>Maximum Number of Undo Actions</summary>
|
||||||
|
<description>Maximum number of actions that gedit will be able to undo or redo. Use “-1” for unlimited number of actions.</description>
|
||||||
|
</key>
|
||||||
|
<key name="wrap-mode" enum="org.gnome.gedit.WrapMode">
|
||||||
|
<aliases>
|
||||||
|
<alias value='GTK_WRAP_NONE' target='none'/>
|
||||||
|
<alias value='GTK_WRAP_WORD' target='word'/>
|
||||||
|
<alias value='GTK_WRAP_CHAR' target='char'/>
|
||||||
|
</aliases>
|
||||||
|
<default>'word'</default>
|
||||||
|
<summary>Line Wrapping Mode</summary>
|
||||||
|
<description>Specifies how to wrap long lines in the editing area. Use “none” for no wrapping, “word” for wrapping at word boundaries, and “char” for wrapping at individual character boundaries. Note that the values are case-sensitive, so make sure they appear exactly as mentioned here.</description>
|
||||||
|
</key>
|
||||||
|
<key name="wrap-last-split-mode" enum="org.gnome.gedit.WrapMode">
|
||||||
|
<aliases>
|
||||||
|
<alias value='GTK_WRAP_WORD' target='word'/>
|
||||||
|
<alias value='GTK_WRAP_CHAR' target='char'/>
|
||||||
|
</aliases>
|
||||||
|
<default>'word'</default>
|
||||||
|
<summary>Last split mode choice for line wrapping mode</summary>
|
||||||
|
<description>Specifies the last split mode used with line wrapping mode, so that when wrapping mode is off we still remember the split mode choice. Use “word” for wrapping at word boundaries, and “char” for wrapping at individual character boundaries.</description>
|
||||||
|
</key>
|
||||||
|
<key name="tabs-size" type="u">
|
||||||
|
<range min="1" max="24"/>
|
||||||
|
<default>8</default>
|
||||||
|
<summary>Tab Size</summary>
|
||||||
|
<description>Specifies the number of spaces that should be displayed instead of Tab characters.</description>
|
||||||
|
</key>
|
||||||
|
<key name="insert-spaces" type="b">
|
||||||
|
<default>false</default>
|
||||||
|
<summary>Insert spaces</summary>
|
||||||
|
<description>Whether gedit should insert spaces instead of tabs.</description>
|
||||||
|
</key>
|
||||||
|
<key name="auto-indent" type="b">
|
||||||
|
<default>true</default>
|
||||||
|
<summary>Automatic indent</summary>
|
||||||
|
<description>Whether gedit should enable automatic indentation.</description>
|
||||||
|
</key>
|
||||||
|
<key name="display-line-numbers" type="b">
|
||||||
|
<default>true</default>
|
||||||
|
<summary>Display Line Numbers</summary>
|
||||||
|
<description>Whether gedit should display line numbers in the editing area.</description>
|
||||||
|
</key>
|
||||||
|
<key name="highlight-current-line" type="b">
|
||||||
|
<default>true</default>
|
||||||
|
<summary>Highlight Current Line</summary>
|
||||||
|
<description>Whether gedit should highlight the current line.</description>
|
||||||
|
</key>
|
||||||
|
<key name="bracket-matching" type="b">
|
||||||
|
<default>true</default>
|
||||||
|
<summary>Highlight Matching Brackets</summary>
|
||||||
|
<description>Whether gedit should highlight matching brackets.</description>
|
||||||
|
</key>
|
||||||
|
<key name="display-right-margin" type="b">
|
||||||
|
<default>false</default>
|
||||||
|
<summary>Display Right Margin</summary>
|
||||||
|
<description>Whether gedit should display the right margin in the editing area.</description>
|
||||||
|
</key>
|
||||||
|
<key name="right-margin-position" type="u">
|
||||||
|
<default>80</default>
|
||||||
|
<summary>Right Margin Position</summary>
|
||||||
|
<description>Specifies the position of the right margin.</description>
|
||||||
|
</key>
|
||||||
|
<key name="smart-home-end" enum="org.gnome.gedit.SmartHomeEnd">
|
||||||
|
<aliases>
|
||||||
|
<alias value='DISABLED' target='disabled'/>
|
||||||
|
<alias value='BEFORE' target='before'/>
|
||||||
|
<alias value='AFTER' target='after'/>
|
||||||
|
<alias value='ALWAYS' target='always'/>
|
||||||
|
</aliases>
|
||||||
|
<default>'after'</default>
|
||||||
|
<summary>Smart Home End</summary>
|
||||||
|
<description>Specifies how the cursor moves when the HOME and END keys are pressed. Use “disabled” to always move at the start/end of the line, “after” to move to the start/end of the line the first time the keys are pressed and to the start/end of the text ignoring whitespaces the second time the keys are pressed, “before” to move to the start/end of the text before moving to the start/end of the line and “always” to always move to the start/end of the text instead of the start/end of the line.</description>
|
||||||
|
</key>
|
||||||
|
<key name="restore-cursor-position" type="b">
|
||||||
|
<default>true</default>
|
||||||
|
<summary>Restore Previous Cursor Position</summary>
|
||||||
|
<description>Whether gedit should restore the previous cursor position when a file is loaded.</description>
|
||||||
|
</key>
|
||||||
|
<key name="syntax-highlighting" type="b">
|
||||||
|
<default>true</default>
|
||||||
|
<summary>Enable Syntax Highlighting</summary>
|
||||||
|
<description>Whether gedit should enable syntax highlighting.</description>
|
||||||
|
</key>
|
||||||
|
<key name="search-highlighting" type="b">
|
||||||
|
<default>true</default>
|
||||||
|
<summary>Enable Search Highlighting</summary>
|
||||||
|
<description>Whether gedit should highlight all the occurrences of the searched text.</description>
|
||||||
|
</key>
|
||||||
|
<key name="ensure-trailing-newline" type="b">
|
||||||
|
<default>true</default>
|
||||||
|
<summary>Ensure Trailing Newline</summary>
|
||||||
|
<description>Whether gedit will ensure that documents always end with a trailing newline.</description>
|
||||||
|
</key>
|
||||||
|
</schema>
|
||||||
|
<schema id="org.gnome.gedit.preferences.ui" path="/org/gnome/gedit/preferences/ui/">
|
||||||
|
<key name="show-tabs-mode" enum="org.gnome.gedit.GeditNotebookShowTabsModeType">
|
||||||
|
<default>'auto'</default>
|
||||||
|
<summary>Notebook Show Tabs Mode</summary>
|
||||||
|
<description>Specifies when to show the notebook tabs. Use “never” to never show the tabs, “always” to always show the tabs, and “auto” to show the tabs only when there is more than one tab. Note that the values are case-sensitive, so make sure they appear exactly as mentioned here.</description>
|
||||||
|
</key>
|
||||||
|
<key name="statusbar-visible" type="b">
|
||||||
|
<default>true</default>
|
||||||
|
<summary>Status Bar is Visible</summary>
|
||||||
|
<description>Whether the status bar at the bottom of editing windows should be visible.</description>
|
||||||
|
</key>
|
||||||
|
<key name="side-panel-visible" type="b">
|
||||||
|
<default>false</default>
|
||||||
|
<summary>Side panel is Visible</summary>
|
||||||
|
<description>Whether the side panel at the left of editing windows should be visible.</description>
|
||||||
|
</key>
|
||||||
|
<key name="bottom-panel-visible" type="b">
|
||||||
|
<default>false</default>
|
||||||
|
</key>
|
||||||
|
<key name="theme-variant" enum="org.gnome.gedit.ThemeVariant">
|
||||||
|
<default>'system'</default>
|
||||||
|
<summary>Which theme variant to use</summary>
|
||||||
|
</key>
|
||||||
|
</schema>
|
||||||
|
<schema id="org.gnome.gedit.preferences.print" path="/org/gnome/gedit/preferences/print/">
|
||||||
|
<key name="print-syntax-highlighting" type="b">
|
||||||
|
<default>true</default>
|
||||||
|
<summary>Print Syntax Highlighting</summary>
|
||||||
|
<description>Whether gedit should print syntax highlighting when printing documents.</description>
|
||||||
|
</key>
|
||||||
|
<key name="print-header" type="b">
|
||||||
|
<default>true</default>
|
||||||
|
<summary>Print Header</summary>
|
||||||
|
<description>Whether gedit should include a document header when printing documents.</description>
|
||||||
|
</key>
|
||||||
|
<key name="print-wrap-mode" enum="org.gnome.gedit.WrapMode">
|
||||||
|
<aliases>
|
||||||
|
<alias value='GTK_WRAP_NONE' target='none'/>
|
||||||
|
<alias value='GTK_WRAP_WORD' target='word'/>
|
||||||
|
<alias value='GTK_WRAP_CHAR' target='char'/>
|
||||||
|
</aliases>
|
||||||
|
<default>'word'</default>
|
||||||
|
<summary>Printing Line Wrapping Mode</summary>
|
||||||
|
<description>Specifies how to wrap long lines for printing. Use “none” for no wrapping, “word” for wrapping at word boundaries, and “char” for wrapping at individual character boundaries. Note that the values are case-sensitive, so make sure they appear exactly as mentioned here.</description>
|
||||||
|
</key>
|
||||||
|
<key name="print-line-numbers" type="u">
|
||||||
|
<default>0</default>
|
||||||
|
<summary>Print Line Numbers</summary>
|
||||||
|
<description>If this value is 0, then no line numbers will be inserted when printing a document. Otherwise, gedit will print line numbers every such number of lines.</description>
|
||||||
|
</key>
|
||||||
|
<key name="print-font-body-pango" type="s">
|
||||||
|
<!-- Translators: This is a GSettings default value. Do NOT change or localize the quotation marks! -->
|
||||||
|
<default l10n="messages">'Monospace 9'</default>
|
||||||
|
<summary>Body Font for Printing</summary>
|
||||||
|
<description>Specifies the font to use for a document’s body when printing documents.</description>
|
||||||
|
</key>
|
||||||
|
<key name="print-font-header-pango" type="s">
|
||||||
|
<!-- Translators: This is a GSettings default value. Do NOT change or localize the quotation marks! -->
|
||||||
|
<default l10n="messages">'Sans 11'</default>
|
||||||
|
<summary>Header Font for Printing</summary>
|
||||||
|
<description>Specifies the font to use for page headers when printing a document. This will only take effect if the “Print Header” option is turned on.</description>
|
||||||
|
</key>
|
||||||
|
<key name="print-font-numbers-pango" type="s">
|
||||||
|
<!-- Translators: This is a GSettings default value. Do NOT change or localize the quotation marks! -->
|
||||||
|
<default l10n="messages">'Sans 8'</default>
|
||||||
|
<summary>Line Number Font for Printing</summary>
|
||||||
|
<description>Specifies the font to use for line numbers when printing. This will only take effect if the “Print Line Numbers” option is non-zero.</description>
|
||||||
|
</key>
|
||||||
|
<key name="margin-left" type="d">
|
||||||
|
<default>25</default>
|
||||||
|
<summary>Margin Left</summary>
|
||||||
|
<description>The left margin, in millimeters.</description>
|
||||||
|
</key>
|
||||||
|
<key name="margin-top" type="d">
|
||||||
|
<default>15</default>
|
||||||
|
<summary>Margin Top</summary>
|
||||||
|
<description>The top margin, in millimeters.</description>
|
||||||
|
</key>
|
||||||
|
<key name="margin-right" type="d">
|
||||||
|
<default>25</default>
|
||||||
|
<summary>Margin Right</summary>
|
||||||
|
<description>The right margin, in millimeters.</description>
|
||||||
|
</key>
|
||||||
|
<key name="margin-bottom" type="d">
|
||||||
|
<default>25</default>
|
||||||
|
<summary>Margin Bottom</summary>
|
||||||
|
<description>The bottom margin, in millimeters.</description>
|
||||||
|
</key>
|
||||||
|
</schema>
|
||||||
|
<schema id="org.gnome.gedit.preferences.encodings" path="/org/gnome/gedit/preferences/encodings/">
|
||||||
|
<key name="candidate-encodings" type="as">
|
||||||
|
<default>['']</default>
|
||||||
|
<summary>Candidate Encodings</summary>
|
||||||
|
<description>List of candidate encodings shown in the Character Encoding menu in the open/save file chooser.
|
||||||
|
“CURRENT” represents the current locale encoding. Only recognized encodings are used.
|
||||||
|
The default value is the empty list, in which case gedit will choose good defaults depending on the country and language.</description>
|
||||||
|
</key>
|
||||||
|
</schema>
|
||||||
|
<schema id="org.gnome.gedit.state" path="/org/gnome/gedit/state/">
|
||||||
|
<child name="window" schema="org.gnome.gedit.state.window"/>
|
||||||
|
<child name="file-chooser" schema="org.gnome.gedit.state.file-chooser"/>
|
||||||
|
<child name="history-entry" schema="org.gnome.gedit.state.history-entry"/>
|
||||||
|
</schema>
|
||||||
|
<schema id="org.gnome.gedit.state.window" path="/org/gnome/gedit/state/window/">
|
||||||
|
<key name="maximized" type="b">
|
||||||
|
<default>false</default>
|
||||||
|
<summary>Maximized</summary>
|
||||||
|
<description>Whether the main window should start maximized.</description>
|
||||||
|
</key>
|
||||||
|
<key name="width" type="i">
|
||||||
|
<default>900</default>
|
||||||
|
<summary>Width</summary>
|
||||||
|
<description>The width of the main window.</description>
|
||||||
|
</key>
|
||||||
|
<key name="height" type="i">
|
||||||
|
<default>700</default>
|
||||||
|
<summary>Height</summary>
|
||||||
|
<description>The height of the main window.</description>
|
||||||
|
</key>
|
||||||
|
<key name="side-panel-size" type="i">
|
||||||
|
<default>200</default>
|
||||||
|
</key>
|
||||||
|
<key name="side-panel-active-page" type="s">
|
||||||
|
<default>''</default>
|
||||||
|
</key>
|
||||||
|
<key name="bottom-panel-size" type="i">
|
||||||
|
<default>140</default>
|
||||||
|
</key>
|
||||||
|
<key name="bottom-panel-active-page" type="s">
|
||||||
|
<default>''</default>
|
||||||
|
</key>
|
||||||
|
</schema>
|
||||||
|
<schema id="org.gnome.gedit.state.file-chooser" path="/org/gnome/gedit/state/file-chooser/">
|
||||||
|
<key name="filter-id" type="i">
|
||||||
|
<default>0</default>
|
||||||
|
</key>
|
||||||
|
<key name="open-recent" type="b">
|
||||||
|
<default>true</default>
|
||||||
|
</key>
|
||||||
|
</schema>
|
||||||
|
<schema id="org.gnome.gedit.state.history-entry" path="/org/gnome/gedit/state/history-entry/">
|
||||||
|
<key name="search-for-entry" type="as">
|
||||||
|
<default>['']</default>
|
||||||
|
</key>
|
||||||
|
<key name="replace-with-entry" type="as">
|
||||||
|
<default>['']</default>
|
||||||
|
</key>
|
||||||
|
</schema>
|
||||||
|
<schema id="org.gnome.gedit.plugins" path="/org/gnome/gedit/plugins/">
|
||||||
|
<key name="active-plugins" type="as">
|
||||||
|
<default>[@ACTIVE_PLUGINS@]</default>
|
||||||
|
<summary>Active plugins</summary>
|
||||||
|
<description>List of active plugins.</description>
|
||||||
|
</key>
|
||||||
|
</schema>
|
||||||
|
</schemalist>
|
52
data/org.gnome.gedit.metainfo.xml.in
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- Copyright 2014 Paolo Borelli <pborelli@gnome.org> -->
|
||||||
|
<component type="desktop-application">
|
||||||
|
<id>org.gnome.gedit.desktop</id>
|
||||||
|
<metadata_license>CC0-1.0</metadata_license>
|
||||||
|
<project_license>GPL-2.0+</project_license>
|
||||||
|
<name>gedit</name>
|
||||||
|
<summary>Text editor</summary>
|
||||||
|
<description>
|
||||||
|
<p>
|
||||||
|
gedit is an easy-to-use and general-purpose text editor. Its development
|
||||||
|
started in 1998, at the beginnings of the GNOME project, with a good
|
||||||
|
integration with that desktop environment.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
You can use it to write simple notes and documents, or you can enable more
|
||||||
|
advanced features that are useful for software development.
|
||||||
|
</p>
|
||||||
|
</description>
|
||||||
|
<kudos>
|
||||||
|
<kudo>HiDpiIcon</kudo>
|
||||||
|
<kudo>HighContrast</kudo>
|
||||||
|
<kudo>UserDocs</kudo>
|
||||||
|
</kudos>
|
||||||
|
<screenshots>
|
||||||
|
<screenshot type="default">
|
||||||
|
<image>https://gitlab.gnome.org/swilmet/gedit-extra/-/raw/main/screenshots/screenshot.png</image>
|
||||||
|
</screenshot>
|
||||||
|
</screenshots>
|
||||||
|
<url type="homepage">https://gedit-technology.github.io/apps/gedit/</url>
|
||||||
|
<url type="bugtracker">https://gedit-technology.github.io/apps/gedit/reporting-bugs.html</url>
|
||||||
|
<url type="help">https://gedit-technology.github.io/user-manuals/gedit/</url>
|
||||||
|
<url type="translate">https://wiki.gnome.org/TranslationProject</url>
|
||||||
|
<developer id="gnome.org">
|
||||||
|
<name>The gedit team</name>
|
||||||
|
</developer>
|
||||||
|
<update_contact>swilmet@mailfence.com</update_contact>
|
||||||
|
<launchable type="desktop-id">org.gnome.gedit.desktop</launchable>
|
||||||
|
<translation type="gettext">gedit</translation>
|
||||||
|
<content_rating type="oars-1.1" />
|
||||||
|
<releases>
|
||||||
|
<!-- Beware for alpha/beta/rc, example: version="44~beta" -->
|
||||||
|
<release version="48.1" date="2024-12-07" />
|
||||||
|
<release version="48.0" date="2024-09-14" />
|
||||||
|
<release version="47.0" date="2024-04-27" />
|
||||||
|
<release version="46.1" date="2023-08-06" />
|
||||||
|
<release version="46.0" date="2023-07-29" />
|
||||||
|
<release version="45.0" date="2023-06-23" />
|
||||||
|
<release version="44.1" date="2023-01-04" />
|
||||||
|
<release version="44.0" date="2023-01-01" />
|
||||||
|
</releases>
|
||||||
|
</component>
|
3
data/org.gnome.gedit.service.in
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
[D-BUS Service]
|
||||||
|
Name=org.gnome.gedit
|
||||||
|
Exec=@bindir@/gedit --gapplication-service
|
4
data/privacy-policy.md
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
Privacy policy of gedit
|
||||||
|
=======================
|
||||||
|
|
||||||
|
We don't store any data.
|
BIN
data/screenshot.png
Normal file
After Width: | Height: | Size: 130 KiB |
97
docs/build.md
Normal file
|
@ -0,0 +1,97 @@
|
||||||
|
gedit installation by building the source code
|
||||||
|
==============================================
|
||||||
|
|
||||||
|
Recommendation to install in a separate prefix
|
||||||
|
----------------------------------------------
|
||||||
|
|
||||||
|
Once you have built gedit from source, you cannot run the application from its
|
||||||
|
build directory: you need to install it with `ninja install`. For this reason it
|
||||||
|
is highly recommended that you install in a separate prefix instead of
|
||||||
|
overwriting your system binaries.
|
||||||
|
|
||||||
|
Note however that when running gedit from a custom prefix you will need to set
|
||||||
|
many environment variables accordingly, for instance `PATH` and `XDG_DATA_DIRS`.
|
||||||
|
|
||||||
|
There exists several tools that GNOME developers use to take care of all of
|
||||||
|
this. See the _Tools_ section below.
|
||||||
|
|
||||||
|
Installation of the dependencies
|
||||||
|
--------------------------------
|
||||||
|
|
||||||
|
You need to have all gedit dependencies installed, with recent enough versions.
|
||||||
|
If a dependency is missing or is too old, the build configuration fails (you can
|
||||||
|
try to run the build configuration command for gedit until it succeeds, see the
|
||||||
|
procedure below).
|
||||||
|
|
||||||
|
You can install the dependencies by installing packages provided by your
|
||||||
|
operating system, for example on Fedora:
|
||||||
|
```
|
||||||
|
# dnf builddep gedit
|
||||||
|
```
|
||||||
|
|
||||||
|
But if your version of gedit provided by the OS differs too much from the
|
||||||
|
version of gedit you want to build from source, you'll need to install the new
|
||||||
|
dependencies from source too, and it can become a complicated task if you do it
|
||||||
|
manually.
|
||||||
|
|
||||||
|
Also, during gedit development, gedit may depend on a not-yet-released
|
||||||
|
development version of a dependency. So certain dependencies may need to be
|
||||||
|
installed from Git.
|
||||||
|
|
||||||
|
That's why if you have difficulties installing recent enough versions of the
|
||||||
|
dependencies, it is usually easier to use one of the tools explained in the next
|
||||||
|
section.
|
||||||
|
|
||||||
|
Tools
|
||||||
|
-----
|
||||||
|
|
||||||
|
There are several tools available that take care of the following:
|
||||||
|
- Install in a separate prefix.
|
||||||
|
- Build or install dependencies.
|
||||||
|
- Plus, for some tools: run in a container/sandbox.
|
||||||
|
|
||||||
|
GNOME developers usually use one of these tools:
|
||||||
|
- [Toolbx](https://containertoolbx.org/) (probably the easiest)
|
||||||
|
- Or [Flatpak](https://flatpak.org/)
|
||||||
|
- Or [JHBuild](https://gitlab.gnome.org/GNOME/jhbuild)
|
||||||
|
|
||||||
|
General tips for gedit:
|
||||||
|
- At the time of writing, no need to build GLib or GTK from source, taking their
|
||||||
|
latest stable versions are sufficient.
|
||||||
|
|
||||||
|
JHBuild tips:
|
||||||
|
- Try `ignore_suggests = True` in your jhbuildrc to have fewer dependencies to
|
||||||
|
build (see the difference with "jhbuild list gedit"). Another solution is to
|
||||||
|
put some modules in the skip variable in jhbuildrc.
|
||||||
|
- Note that the moduleset for gedit may be out-of-date.
|
||||||
|
|
||||||
|
Building the gedit module manually
|
||||||
|
----------------------------------
|
||||||
|
|
||||||
|
If you use one of the above tools, you don't need all the explanations in this
|
||||||
|
section. But it can be instructive.
|
||||||
|
|
||||||
|
gedit uses the [Meson](https://mesonbuild.com/) build system.
|
||||||
|
|
||||||
|
Once the dependencies are installed, here are simple procedures to finally build
|
||||||
|
the gedit module from source.
|
||||||
|
|
||||||
|
### Installation onto the system
|
||||||
|
|
||||||
|
**Warning**: this procedure doesn't install in a separate prefix, so it may
|
||||||
|
overwrite your system binaries.
|
||||||
|
|
||||||
|
```
|
||||||
|
$ cd build/
|
||||||
|
$ meson setup # Build configuration
|
||||||
|
$ ninja # Build
|
||||||
|
[ Become root if necessary ]
|
||||||
|
$ ninja install # Installation
|
||||||
|
```
|
||||||
|
|
||||||
|
### Installation in a separate prefix
|
||||||
|
|
||||||
|
Just change the above `meson setup` command by:
|
||||||
|
```
|
||||||
|
$ meson setup --prefix /an/other/path
|
||||||
|
```
|
BIN
docs/class-diagram.dia
Normal file
38
docs/common-bugs.md
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
Common gedit bugs
|
||||||
|
=================
|
||||||
|
|
||||||
|
This page documents common bugs in gedit. If you find your problem in this page,
|
||||||
|
_please do not report a new bug for it_.
|
||||||
|
|
||||||
|
Problem with very long lines
|
||||||
|
----------------------------
|
||||||
|
|
||||||
|
Very long lines (e.g. a wrapped line that takes the whole screen) are not well
|
||||||
|
supported by gedit, there can be performance problems or freezes.
|
||||||
|
|
||||||
|
[GitLab issue](https://gitlab.gnome.org/World/gedit/gedit/-/issues/513).
|
||||||
|
|
||||||
|
Problem with very large files
|
||||||
|
-----------------------------
|
||||||
|
|
||||||
|
Large files are not well supported, gedit should ask for confirmation when
|
||||||
|
opening such files, providing a solution.
|
||||||
|
|
||||||
|
[GitLab issue](https://gitlab.gnome.org/World/gedit/gedit/-/issues/11).
|
||||||
|
|
||||||
|
Hyphen/dash inserted for text wrapping
|
||||||
|
--------------------------------------
|
||||||
|
|
||||||
|
It should be disabled in a text editor like gedit, the hyphen is not part of
|
||||||
|
the content.
|
||||||
|
|
||||||
|
[GitLab issue](https://gitlab.gnome.org/World/gedit/gedit/-/issues/365).
|
||||||
|
|
||||||
|
Recently fixed
|
||||||
|
--------------
|
||||||
|
|
||||||
|
### View does not scroll to the end of the text in some cases (text cut off)
|
||||||
|
|
||||||
|
Fixed in 40.2, 41.1, 42.2 and >= 43.
|
||||||
|
|
||||||
|
[GitLab issue](https://gitlab.gnome.org/World/gedit/gedit/-/issues/42).
|
80
docs/gedit-development-getting-started.md
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
gedit development - getting started
|
||||||
|
===================================
|
||||||
|
|
||||||
|
The following explanations can be improved over time, if you see something
|
||||||
|
missing, a feedback is welcome.
|
||||||
|
|
||||||
|
Programming languages and paradigms
|
||||||
|
-----------------------------------
|
||||||
|
|
||||||
|
gedit is mostly written in C, with some plugins in Python. The
|
||||||
|
[Meson](https://mesonbuild.com/) build system is used.
|
||||||
|
|
||||||
|
The code is object-oriented and event-driven. In C, it's thanks to the use of
|
||||||
|
the GObject library (see next section). If you open some `*.c` or `*.h` files,
|
||||||
|
you may be frightened but – don't panic – it's just some C/GObject boilerplate
|
||||||
|
code, and that boilerplate can be generated by a tool. So once you've learned
|
||||||
|
GObject, you will no longer be afraid ;-)
|
||||||
|
|
||||||
|
Libraries used
|
||||||
|
--------------
|
||||||
|
|
||||||
|
As every GNOME application, gedit uses the GLib, GObject and GTK libraries. To
|
||||||
|
modify the gedit source code, you should be familiar with those libraries. See
|
||||||
|
the [GTK website](https://www.gtk.org/) and
|
||||||
|
[The GLib/GTK Development Platform – A Getting Started Guide](https://github.com/gdev-technology/glib-gtk-learning).
|
||||||
|
|
||||||
|
The main "text area" in gedit is a GtkTextView widget. This widget is part of
|
||||||
|
GTK. You can learn it with the
|
||||||
|
[GtkTextView tutorial](http://www.bravegnu.org/gtktext/). The tutorial is a bit
|
||||||
|
old but the GtkTextView API has not changed a lot. (By the way, contributing to
|
||||||
|
update the tutorial would be a useful task!).
|
||||||
|
|
||||||
|
GtkTextView provides the basis, and is extended by other libraries to add more
|
||||||
|
features. See [Gedit Technology](https://gedit-technology.github.io/).
|
||||||
|
|
||||||
|
For its plugin system, gedit uses
|
||||||
|
[libpeas](https://wiki.gnome.org/Projects/Libpeas).
|
||||||
|
|
||||||
|
Plugins may have other dependencies, for example the spell-checking plugin uses
|
||||||
|
[gspell](https://gitlab.gnome.org/GNOME/gspell).
|
||||||
|
|
||||||
|
gedit architecture
|
||||||
|
------------------
|
||||||
|
|
||||||
|
The [gedit git repository](https://gitlab.gnome.org/World/gedit/gedit) contains:
|
||||||
|
- The "gedit core" in the `gedit/` directory.
|
||||||
|
- The default plugins in `plugins/`.
|
||||||
|
|
||||||
|
There is also the
|
||||||
|
[gedit-plugins git repository](https://gitlab.gnome.org/World/gedit/gedit-plugins)
|
||||||
|
for additional official plugins.
|
||||||
|
|
||||||
|
The gedit core provides:
|
||||||
|
- A basic text editor.
|
||||||
|
- The integration of libpeas, with an API for plugins.
|
||||||
|
|
||||||
|
There is a class diagram of gedit core in the file
|
||||||
|
[class-diagram.dia](class-diagram.dia) (but it may be outdated, see the Git log
|
||||||
|
for that file).
|
||||||
|
|
||||||
|
Build/Installation
|
||||||
|
------------------
|
||||||
|
|
||||||
|
See the file [build.md](build.md).
|
||||||
|
|
||||||
|
Suggestions
|
||||||
|
-----------
|
||||||
|
|
||||||
|
A good way to learn a lot of things is to write a new plugin (it can be a
|
||||||
|
third-party plugin at first).
|
||||||
|
|
||||||
|
Improving the API reference of the gedit core would be useful, because some
|
||||||
|
parts lack proper documentation.
|
||||||
|
|
||||||
|
A potentially easy task is to fix compilation warnings, for example when a
|
||||||
|
deprecated function is used. If you encounter a runtime warning or critical
|
||||||
|
message, it is also a good idea to fix it.
|
||||||
|
|
||||||
|
Note that gedit is an old piece of software. Some parts are legacy code and
|
||||||
|
would benefit from some refactoring.
|
45
docs/how-to-write-a-gedit-plugin.md
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
How to write a gedit plugin
|
||||||
|
===========================
|
||||||
|
|
||||||
|
The [gedit-development-getting-started.md](gedit-development-getting-started.md)
|
||||||
|
documentation is a good start.
|
||||||
|
|
||||||
|
Programming language for a gedit plugin
|
||||||
|
---------------------------------------
|
||||||
|
|
||||||
|
The preferred language is the C language, that way the code can be easily
|
||||||
|
refactored to be included in a library.
|
||||||
|
|
||||||
|
Rust, C++ and Vala plugins are possible too since they are equivalent to C.
|
||||||
|
|
||||||
|
Python plugins are possible too.
|
||||||
|
|
||||||
|
### What if I prefer to write in Ruby/JS/Scheme/Perl/C#/modula-2/Oz/whatever…
|
||||||
|
|
||||||
|
While GObject allows you to use many other languages, using more than one
|
||||||
|
interpreter in the same process is not possible, not only because of bloat and
|
||||||
|
performance, but also because different interpreted languages cannot manage
|
||||||
|
garbage collections of GObjects at the same time: see
|
||||||
|
[this email](https://mail.gnome.org/archives/desktop-devel-list/2010-August/msg00036.html).
|
||||||
|
|
||||||
|
The gedit developers have chosen Python as the interpreted language.
|
||||||
|
|
||||||
|
API reference
|
||||||
|
-------------
|
||||||
|
|
||||||
|
Build gedit with `-D gtk_doc=true`, you can then browse the API reference in the
|
||||||
|
[Devhelp](https://wiki.gnome.org/Apps/Devhelp) application.
|
||||||
|
|
||||||
|
To know how to write a plugin, refer to the
|
||||||
|
[libpeas](https://wiki.gnome.org/Projects/Libpeas) documentation as well.
|
||||||
|
|
||||||
|
More documentation and tips
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
More documentation, for example a tutorial, would be useful. In the meantime,
|
||||||
|
the recommended thing to do is to see how core gedit plugins are implemented.
|
||||||
|
|
||||||
|
### Unofficial documentation and tutorials (may be outdated)
|
||||||
|
|
||||||
|
- [Writing plugins in Python](https://wiki.gnome.org/Apps/Gedit/PythonPluginHowTo) (a little outdated)
|
||||||
|
- [Writing plugins in Vala](https://wiki.gnome.org/Projects/Vala/Gedit3PluginSample) (maybe outdated)
|
7
docs/misc.md
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
gedit misc notes
|
||||||
|
================
|
||||||
|
|
||||||
|
Various links
|
||||||
|
-------------
|
||||||
|
|
||||||
|
- [gedit wiki attic](https://wiki.gnome.org/Apps/Gedit/Attic)
|
314
docs/reference/api-breaks.xml
Normal file
|
@ -0,0 +1,314 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
|
||||||
|
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"
|
||||||
|
[
|
||||||
|
<!ENTITY % local.common.attrib "xmlns:xi CDATA #FIXED 'http://www.w3.org/2003/XInclude'">
|
||||||
|
]>
|
||||||
|
|
||||||
|
<part id="api-breaks">
|
||||||
|
<title>API Breaks</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
gedit is a quite old piece of software (created in 1998, at the beginnings
|
||||||
|
of the GNOME project), and as every software, the code evolves during its
|
||||||
|
lifetime. So there are sometimes API breaks for gedit plugins, there are no
|
||||||
|
API stability guarantees.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<refsect1>
|
||||||
|
<title>47 -> 48</title>
|
||||||
|
<itemizedlist>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
<link linkend="gedit-window-get-bottom-panel">gedit_window_get_bottom_panel()</link>
|
||||||
|
now returns a <link linkend="TeplPanel">TeplPanel</link>.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</itemizedlist>
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1>
|
||||||
|
<title>46 -> 47</title>
|
||||||
|
<itemizedlist>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The <link linkend="GeditWindow-active-tab-changed">GeditWindow::active-tab-changed</link>
|
||||||
|
signal has a different API: the tab parameter has been removed and the
|
||||||
|
signal is also called when the active tab becomes NULL.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The <code>GeditWindow::active-tab-state-changed</code> signal has been
|
||||||
|
removed. It was unused and was anyway there for convenience (it was
|
||||||
|
not an essential API).
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The <code>GeditWindow::tabs-reordered</code> signal has been removed.
|
||||||
|
It was unused. Also, functions like
|
||||||
|
<link linkend="gedit-window-get-documents">gedit_window_get_documents()</link>
|
||||||
|
don't specify the order in which the objects are listed.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The <code>GeditTab::drop-uris</code> signal has been removed. You can
|
||||||
|
use the <link linkend="GeditView-drop-uris">GeditView::drop-uris</link>
|
||||||
|
signal instead (it is the same).
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The <code>gedit_utils_location_get_dirname_for_display()</code>
|
||||||
|
function has been removed.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The <code>gedit_app_set_window_title()</code> function is now private.
|
||||||
|
The window title is handled by the gedit core and should not be
|
||||||
|
altered by plugins.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The <code>gedit_app_process_window_event()</code> function is now
|
||||||
|
private. The function should be only useful to the gedit core, not
|
||||||
|
plugins.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</itemizedlist>
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1>
|
||||||
|
<title>45 -> 46</title>
|
||||||
|
<itemizedlist>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The <link linkend="gedit-window-get-side-panel">gedit_window_get_side_panel()</link>
|
||||||
|
function now returns a <link linkend="TeplPanel">TeplPanel</link>.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The <code>gedit_statusbar_new()</code> and
|
||||||
|
<code>gedit_statusbar_set_window_state()</code> functions have been
|
||||||
|
removed.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The <code>gedit_utils_set_atk_name_description()</code> function has
|
||||||
|
been removed.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</itemizedlist>
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1>
|
||||||
|
<title>44 -> 45</title>
|
||||||
|
<itemizedlist>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Vala plugins need to rely on the GObject Introspection file instead of
|
||||||
|
the vapi. The latter is no longer generated.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The <code>gedit_window_create_tab_from_location()</code> and
|
||||||
|
<code>gedit_window_create_tab_from_stream()</code> functions have been
|
||||||
|
removed, use
|
||||||
|
<link linkend="gedit-window-create-tab">gedit_window_create_tab()</link>
|
||||||
|
followed by
|
||||||
|
<link linkend="gedit-tab-load-file">gedit_tab_load_file()</link> or
|
||||||
|
<link linkend="gedit-tab-load-stream">gedit_tab_load_stream()</link>
|
||||||
|
instead.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</itemizedlist>
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1>
|
||||||
|
<title>43 -> 44</title>
|
||||||
|
<itemizedlist>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
When an URI is added to the
|
||||||
|
<link linkend="GtkRecentManager">GtkRecentManager</link>,
|
||||||
|
the <code>groups</code> field of
|
||||||
|
<link linkend="GtkRecentData">GtkRecentData</link>
|
||||||
|
is no longer set. You can rely on the application name instead.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The <code>gedit_document_get_language()</code> function has been
|
||||||
|
removed, use
|
||||||
|
<link linkend="gtk-source-buffer-get-language">gtk_source_buffer_get_language()</link>
|
||||||
|
instead.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The <code>gedit_document_get_short_name_for_display()</code> function has been
|
||||||
|
removed, use
|
||||||
|
<link linkend="tepl-file-get-short-name">tepl_file_get_short_name()</link>
|
||||||
|
instead.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The <code>gedit_document_is_untitled()</code> function has been
|
||||||
|
removed, use
|
||||||
|
<link linkend="tepl-file-get-location">tepl_file_get_location()</link>
|
||||||
|
instead. If the location is <code>NULL</code>, it means that the
|
||||||
|
document is untitled. The <link linkend="TeplFile">TeplFile</link>
|
||||||
|
object should be retrieved with
|
||||||
|
<link linkend="tepl-buffer-get-file">tepl_buffer_get_file()</link>
|
||||||
|
(<link linkend="GeditDocument">GeditDocument</link> inherits from
|
||||||
|
<link linkend="TeplBuffer">TeplBuffer</link>).
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The <code>gedit_statusbar_set_overwrite()</code>
|
||||||
|
and <code>gedit_statusbar_clear_overwrite()</code>
|
||||||
|
functions have been removed.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</itemizedlist>
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1>
|
||||||
|
<title>3.38 -> 40</title>
|
||||||
|
<itemizedlist>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
All previously deprecated APIs have been removed.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The <code>GeditProgressInfoBar</code> class has been removed, you can
|
||||||
|
use <link linkend="TeplProgressInfoBar">TeplProgressInfoBar</link>
|
||||||
|
instead.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
<link linkend="GeditDocument">GeditDocument</link> is now a subclass
|
||||||
|
of <link linkend="TeplBuffer">TeplBuffer</link>.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The <code>GeditDocument::cursor-moved</code> signal has been removed.
|
||||||
|
You can use the <link linkend="TeplBuffer">TeplBuffer</link> API
|
||||||
|
instead.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The <code>gedit_document_get_uri_for_display()</code> function has
|
||||||
|
been removed from the public API.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The <code>GeditDocument:shortname</code> property has been removed.
|
||||||
|
You can use the <link linkend="TeplFile">TeplFile</link> API instead.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The <code>gedit_document_is_untouched()</code> function has been
|
||||||
|
removed. You can use the <link linkend="TeplBuffer">TeplBuffer</link>
|
||||||
|
API instead.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The <code>gedit_view_set_font()</code> function has been removed.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
<code>DEBUG_METADATA</code> has been removed.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</itemizedlist>
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1>
|
||||||
|
<title>3.36.0 -> 3.37.1</title>
|
||||||
|
<itemizedlist>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
All previously deprecated APIs have been removed.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The lockdown support has been removed (for the
|
||||||
|
org.gnome.desktop.lockdown GSettings). So the
|
||||||
|
<code>gedit_app_get_lockdown()</code> function has been removed.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The <code>GBOOLEAN_TO_POINTER()</code> and
|
||||||
|
<code>GPOINTER_TO_BOOLEAN()</code> macros have been removed from
|
||||||
|
<code>gedit-utils.h</code>.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The <code>gedit_utils_get_current_workspace()</code>,
|
||||||
|
<code>gedit_utils_get_window_workspace()</code> and
|
||||||
|
<code>gedit_utils_get_current_viewport()</code> functions have been
|
||||||
|
removed because workspaces information is not available on Wayland.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</itemizedlist>
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1>
|
||||||
|
<title>3.34.0 -> 3.35.2</title>
|
||||||
|
<itemizedlist>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
All previously deprecated APIs have been removed.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The <code>GeditDocument:use-gvfs-metadata</code> property has been
|
||||||
|
removed. But there was anyway a warning for not using that property in
|
||||||
|
a gedit plugin.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
For <link linkend="gedit-document-get-metadata">gedit_document_get_metadata()</link>
|
||||||
|
and <link linkend="gedit-document-set-metadata">gedit_document_set_metadata()</link>,
|
||||||
|
the key names should now have the prefix <code>"gedit-"</code> with
|
||||||
|
possibly an additional namespace for the plugin name, for example
|
||||||
|
<code>"gedit-spell-foobar"</code>. So the key names are now the same
|
||||||
|
regardless of the operating system, and the key names should no longer
|
||||||
|
start with <code>"metadata::"</code>.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</itemizedlist>
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1>
|
||||||
|
<title>For previous gedit versions</title>
|
||||||
|
<para>
|
||||||
|
See the
|
||||||
|
<ulink url="https://wiki.gnome.org/Apps/Gedit/Attic/Old_API_Changes">Old API Changes wiki page</ulink>.
|
||||||
|
</para>
|
||||||
|
</refsect1>
|
||||||
|
</part>
|
80
docs/reference/gedit-docs.xml
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
|
||||||
|
"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
|
||||||
|
<book id="index" xmlns:xi="http://www.w3.org/2003/XInclude">
|
||||||
|
<bookinfo>
|
||||||
|
<title>gedit Reference Manual</title>
|
||||||
|
</bookinfo>
|
||||||
|
|
||||||
|
<part id="api-reference">
|
||||||
|
<title>API Reference</title>
|
||||||
|
<chapter>
|
||||||
|
<title>Main Classes</title>
|
||||||
|
<xi:include href="xml/gedit-app.xml"/>
|
||||||
|
<xi:include href="xml/gedit-app-activatable.xml"/>
|
||||||
|
<xi:include href="xml/gedit-window.xml"/>
|
||||||
|
<xi:include href="xml/gedit-window-activatable.xml"/>
|
||||||
|
<xi:include href="xml/gedit-tab.xml"/>
|
||||||
|
<xi:include href="xml/gedit-view.xml"/>
|
||||||
|
<xi:include href="xml/gedit-view-activatable.xml"/>
|
||||||
|
<xi:include href="xml/gedit-document.xml"/>
|
||||||
|
</chapter>
|
||||||
|
<chapter>
|
||||||
|
<title>Other</title>
|
||||||
|
<xi:include href="xml/gedit-commands.xml"/>
|
||||||
|
<xi:include href="xml/gedit-encodings-combo-box.xml"/>
|
||||||
|
<xi:include href="xml/gedit-menu-extension.xml"/>
|
||||||
|
<xi:include href="xml/gedit-message-bus.xml"/>
|
||||||
|
<xi:include href="xml/gedit-message.xml"/>
|
||||||
|
<xi:include href="xml/gedit-statusbar.xml"/>
|
||||||
|
<xi:include href="xml/gedit-debug.xml"/>
|
||||||
|
<xi:include href="xml/gedit-utils.xml"/>
|
||||||
|
</chapter>
|
||||||
|
</part>
|
||||||
|
|
||||||
|
<xi:include href="api-breaks.xml"/>
|
||||||
|
|
||||||
|
<part id="annexes">
|
||||||
|
<title>Annexes</title>
|
||||||
|
|
||||||
|
<chapter>
|
||||||
|
<title>Object Hierarchy</title>
|
||||||
|
<xi:include href="xml/tree_index.sgml"/>
|
||||||
|
</chapter>
|
||||||
|
|
||||||
|
<xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include>
|
||||||
|
|
||||||
|
<index>
|
||||||
|
<title>Index of all symbols</title>
|
||||||
|
<xi:include href="xml/api-index-full.xml"><xi:fallback /></xi:include>
|
||||||
|
</index>
|
||||||
|
<index role="deprecated">
|
||||||
|
<title>Index of deprecated symbols</title>
|
||||||
|
<xi:include href="xml/api-index-deprecated.xml"><xi:fallback /></xi:include>
|
||||||
|
</index>
|
||||||
|
<index role="3.4">
|
||||||
|
<title>Index of new symbols in 3.4</title>
|
||||||
|
<xi:include href="xml/api-index-3.4.xml"><xi:fallback /></xi:include>
|
||||||
|
</index>
|
||||||
|
<index role="3.14">
|
||||||
|
<title>Index of new symbols in 3.14</title>
|
||||||
|
<xi:include href="xml/api-index-3.14.xml"><xi:fallback /></xi:include>
|
||||||
|
</index>
|
||||||
|
<index role="45">
|
||||||
|
<title>Index of new symbols in 45</title>
|
||||||
|
<xi:include href="xml/api-index-45.xml"><xi:fallback /></xi:include>
|
||||||
|
</index>
|
||||||
|
<index role="46">
|
||||||
|
<title>Index of new symbols in 46</title>
|
||||||
|
<xi:include href="xml/api-index-46.xml"><xi:fallback /></xi:include>
|
||||||
|
</index>
|
||||||
|
<index role="47">
|
||||||
|
<title>Index of new symbols in 47</title>
|
||||||
|
<xi:include href="xml/api-index-47.xml"><xi:fallback /></xi:include>
|
||||||
|
</index>
|
||||||
|
<index role="48">
|
||||||
|
<title>Index of new symbols in 48</title>
|
||||||
|
<xi:include href="xml/api-index-48.xml"><xi:fallback /></xi:include>
|
||||||
|
</index>
|
||||||
|
</part>
|
||||||
|
</book>
|
322
docs/reference/gedit-sections.txt
Normal file
|
@ -0,0 +1,322 @@
|
||||||
|
<SECTION>
|
||||||
|
<FILE>gedit-app</FILE>
|
||||||
|
<TITLE>GeditApp</TITLE>
|
||||||
|
GeditApp
|
||||||
|
gedit_app_create_window
|
||||||
|
gedit_app_get_main_windows
|
||||||
|
gedit_app_get_views
|
||||||
|
gedit_app_get_documents
|
||||||
|
gedit_app_show_help
|
||||||
|
<SUBSECTION Standard>
|
||||||
|
GEDIT_APP
|
||||||
|
GEDIT_IS_APP
|
||||||
|
GEDIT_TYPE_APP
|
||||||
|
gedit_app_get_type
|
||||||
|
GEDIT_APP_CLASS
|
||||||
|
GEDIT_IS_APP_CLASS
|
||||||
|
GEDIT_APP_GET_CLASS
|
||||||
|
</SECTION>
|
||||||
|
|
||||||
|
<SECTION>
|
||||||
|
<FILE>gedit-app-activatable</FILE>
|
||||||
|
<TITLE>GeditAppActivatable</TITLE>
|
||||||
|
GeditAppActivatable
|
||||||
|
gedit_app_activatable_activate
|
||||||
|
gedit_app_activatable_deactivate
|
||||||
|
gedit_app_activatable_extend_menu
|
||||||
|
<SUBSECTION Standard>
|
||||||
|
GEDIT_TYPE_APP_ACTIVATABLE
|
||||||
|
GEDIT_APP_ACTIVATABLE
|
||||||
|
GEDIT_APP_ACTIVATABLE_IFACE
|
||||||
|
GEDIT_IS_APP_ACTIVATABLE
|
||||||
|
GEDIT_APP_ACTIVATABLE_GET_IFACE
|
||||||
|
gedit_app_activatable_get_type
|
||||||
|
</SECTION>
|
||||||
|
|
||||||
|
<SECTION>
|
||||||
|
<FILE>gedit-commands</FILE>
|
||||||
|
<TITLE>GeditCommands</TITLE>
|
||||||
|
gedit_commands_load_location
|
||||||
|
gedit_commands_load_locations
|
||||||
|
gedit_commands_save_document
|
||||||
|
gedit_commands_save_document_async
|
||||||
|
gedit_commands_save_document_finish
|
||||||
|
gedit_commands_save_all_documents
|
||||||
|
</SECTION>
|
||||||
|
|
||||||
|
<SECTION>
|
||||||
|
<FILE>gedit-document</FILE>
|
||||||
|
<TITLE>GeditDocument</TITLE>
|
||||||
|
GeditDocument
|
||||||
|
gedit_document_new
|
||||||
|
gedit_document_get_file
|
||||||
|
gedit_document_get_content_type
|
||||||
|
gedit_document_get_mime_type
|
||||||
|
gedit_document_set_language
|
||||||
|
gedit_document_get_metadata
|
||||||
|
gedit_document_set_metadata
|
||||||
|
gedit_document_get_search_context
|
||||||
|
gedit_document_set_search_context
|
||||||
|
<SUBSECTION Standard>
|
||||||
|
GEDIT_DOCUMENT
|
||||||
|
GEDIT_IS_DOCUMENT
|
||||||
|
GEDIT_TYPE_DOCUMENT
|
||||||
|
gedit_document_get_type
|
||||||
|
GEDIT_DOCUMENT_CLASS
|
||||||
|
GEDIT_IS_DOCUMENT_CLASS
|
||||||
|
GEDIT_DOCUMENT_GET_CLASS
|
||||||
|
</SECTION>
|
||||||
|
|
||||||
|
<SECTION>
|
||||||
|
<FILE>gedit-encodings-combo-box</FILE>
|
||||||
|
<TITLE>GeditEncodingsComboBox</TITLE>
|
||||||
|
GeditEncodingsComboBox
|
||||||
|
gedit_encodings_combo_box_new
|
||||||
|
gedit_encodings_combo_box_get_selected_encoding
|
||||||
|
gedit_encodings_combo_box_set_selected_encoding
|
||||||
|
<SUBSECTION Standard>
|
||||||
|
GEDIT_ENCODINGS_COMBO_BOX
|
||||||
|
GEDIT_IS_ENCODINGS_COMBO_BOX
|
||||||
|
GEDIT_TYPE_ENCODINGS_COMBO_BOX
|
||||||
|
gedit_encodings_combo_box_get_type
|
||||||
|
GEDIT_ENCODINGS_COMBO_BOX_CLASS
|
||||||
|
GEDIT_IS_ENCODINGS_COMBO_BOX_CLASS
|
||||||
|
GEDIT_ENCODINGS_COMBO_BOX_GET_CLASS
|
||||||
|
</SECTION>
|
||||||
|
|
||||||
|
<SECTION>
|
||||||
|
<FILE>gedit-message-bus</FILE>
|
||||||
|
<TITLE>GeditMessageBus</TITLE>
|
||||||
|
GeditMessageBus
|
||||||
|
GeditMessageCallback
|
||||||
|
GeditMessageBusForeach
|
||||||
|
gedit_message_bus_get_default
|
||||||
|
gedit_message_bus_new
|
||||||
|
gedit_message_bus_lookup
|
||||||
|
gedit_message_bus_register
|
||||||
|
gedit_message_bus_unregister
|
||||||
|
gedit_message_bus_unregister_all
|
||||||
|
gedit_message_bus_is_registered
|
||||||
|
gedit_message_bus_foreach
|
||||||
|
gedit_message_bus_connect
|
||||||
|
gedit_message_bus_disconnect
|
||||||
|
gedit_message_bus_disconnect_by_func
|
||||||
|
gedit_message_bus_block
|
||||||
|
gedit_message_bus_block_by_func
|
||||||
|
gedit_message_bus_unblock
|
||||||
|
gedit_message_bus_unblock_by_func
|
||||||
|
gedit_message_bus_send_message
|
||||||
|
gedit_message_bus_send_message_sync
|
||||||
|
gedit_message_bus_send
|
||||||
|
gedit_message_bus_send_sync
|
||||||
|
<SUBSECTION Standard>
|
||||||
|
GEDIT_MESSAGE_BUS
|
||||||
|
GEDIT_MESSAGE_BUS_CONST
|
||||||
|
GEDIT_IS_MESSAGE_BUS
|
||||||
|
GEDIT_TYPE_MESSAGE_BUS
|
||||||
|
gedit_message_bus_get_type
|
||||||
|
GEDIT_MESSAGE_BUS_CLASS
|
||||||
|
GEDIT_IS_MESSAGE_BUS_CLASS
|
||||||
|
GEDIT_MESSAGE_BUS_GET_CLASS
|
||||||
|
GeditMessageBusPrivate
|
||||||
|
</SECTION>
|
||||||
|
|
||||||
|
<SECTION>
|
||||||
|
<FILE>gedit-message</FILE>
|
||||||
|
<TITLE>GeditMessage</TITLE>
|
||||||
|
GeditMessage
|
||||||
|
gedit_message_get_object_path
|
||||||
|
gedit_message_get_method
|
||||||
|
gedit_message_type_has
|
||||||
|
gedit_message_type_check
|
||||||
|
gedit_message_has
|
||||||
|
gedit_message_is_valid_object_path
|
||||||
|
gedit_message_type_identifier
|
||||||
|
<SUBSECTION Standard>
|
||||||
|
GEDIT_MESSAGE
|
||||||
|
GEDIT_MESSAGE_CONST
|
||||||
|
GEDIT_IS_MESSAGE
|
||||||
|
GEDIT_TYPE_MESSAGE
|
||||||
|
gedit_message_get_type
|
||||||
|
GEDIT_MESSAGE_CLASS
|
||||||
|
GEDIT_IS_MESSAGE_CLASS
|
||||||
|
GEDIT_MESSAGE_GET_CLASS
|
||||||
|
GeditMessagePrivate
|
||||||
|
</SECTION>
|
||||||
|
|
||||||
|
<SECTION>
|
||||||
|
<FILE>gedit-statusbar</FILE>
|
||||||
|
<TITLE>GeditStatusbar</TITLE>
|
||||||
|
GeditStatusbar
|
||||||
|
gedit_statusbar_flash_message
|
||||||
|
<SUBSECTION Standard>
|
||||||
|
GEDIT_STATUSBAR
|
||||||
|
GEDIT_IS_STATUSBAR
|
||||||
|
GEDIT_TYPE_STATUSBAR
|
||||||
|
gedit_statusbar_get_type
|
||||||
|
GEDIT_STATUSBAR_CLASS
|
||||||
|
GEDIT_IS_STATUSBAR_CLASS
|
||||||
|
GEDIT_STATUSBAR_GET_CLASS
|
||||||
|
</SECTION>
|
||||||
|
|
||||||
|
<SECTION>
|
||||||
|
<FILE>gedit-tab</FILE>
|
||||||
|
<TITLE>GeditTab</TITLE>
|
||||||
|
GeditTab
|
||||||
|
GeditTabState
|
||||||
|
gedit_tab_load_file
|
||||||
|
gedit_tab_load_stream
|
||||||
|
gedit_tab_get_view
|
||||||
|
gedit_tab_get_document
|
||||||
|
gedit_tab_get_from_document
|
||||||
|
gedit_tab_get_state
|
||||||
|
gedit_tab_get_auto_save_enabled
|
||||||
|
gedit_tab_set_auto_save_enabled
|
||||||
|
gedit_tab_get_auto_save_interval
|
||||||
|
gedit_tab_set_auto_save_interval
|
||||||
|
gedit_tab_set_info_bar
|
||||||
|
<SUBSECTION Standard>
|
||||||
|
GEDIT_TAB
|
||||||
|
GEDIT_IS_TAB
|
||||||
|
GEDIT_TYPE_TAB
|
||||||
|
gedit_tab_get_type
|
||||||
|
GEDIT_TAB_CLASS
|
||||||
|
GEDIT_IS_TAB_CLASS
|
||||||
|
GEDIT_TAB_GET_CLASS
|
||||||
|
GEDIT_TYPE_TAB_STATE
|
||||||
|
gedit_tab_state_get_type
|
||||||
|
</SECTION>
|
||||||
|
|
||||||
|
<SECTION>
|
||||||
|
<FILE>gedit-view</FILE>
|
||||||
|
GeditViewPrivate
|
||||||
|
<TITLE>GeditView</TITLE>
|
||||||
|
GeditView
|
||||||
|
gedit_view_new
|
||||||
|
<SUBSECTION Standard>
|
||||||
|
GEDIT_VIEW
|
||||||
|
GEDIT_IS_VIEW
|
||||||
|
GEDIT_TYPE_VIEW
|
||||||
|
gedit_view_get_type
|
||||||
|
GEDIT_VIEW_CLASS
|
||||||
|
GEDIT_IS_VIEW_CLASS
|
||||||
|
GEDIT_VIEW_GET_CLASS
|
||||||
|
</SECTION>
|
||||||
|
|
||||||
|
<SECTION>
|
||||||
|
<FILE>gedit-view-activatable</FILE>
|
||||||
|
<TITLE>GeditViewActivatable</TITLE>
|
||||||
|
GeditViewActivatable
|
||||||
|
gedit_view_activatable_activate
|
||||||
|
gedit_view_activatable_deactivate
|
||||||
|
<SUBSECTION Standard>
|
||||||
|
GEDIT_TYPE_VIEW_ACTIVATABLE
|
||||||
|
GEDIT_VIEW_ACTIVATABLE
|
||||||
|
GEDIT_VIEW_ACTIVATABLE_IFACE
|
||||||
|
GEDIT_IS_VIEW_ACTIVATABLE
|
||||||
|
GEDIT_VIEW_ACTIVATABLE_GET_IFACE
|
||||||
|
gedit_view_activatable_get_type
|
||||||
|
</SECTION>
|
||||||
|
|
||||||
|
<SECTION>
|
||||||
|
<FILE>gedit-window</FILE>
|
||||||
|
<TITLE>GeditWindow</TITLE>
|
||||||
|
GeditWindow
|
||||||
|
GeditWindowState
|
||||||
|
gedit_window_create_tab
|
||||||
|
gedit_window_close_tab
|
||||||
|
gedit_window_close_all_tabs
|
||||||
|
gedit_window_close_tabs
|
||||||
|
gedit_window_set_active_tab
|
||||||
|
gedit_window_get_active_tab
|
||||||
|
gedit_window_get_active_view
|
||||||
|
gedit_window_get_active_document
|
||||||
|
gedit_window_get_tab_from_location
|
||||||
|
gedit_window_get_views
|
||||||
|
gedit_window_get_documents
|
||||||
|
gedit_window_get_unsaved_documents
|
||||||
|
gedit_window_get_side_panel
|
||||||
|
gedit_window_get_bottom_panel
|
||||||
|
gedit_window_get_statusbar
|
||||||
|
gedit_window_get_group
|
||||||
|
gedit_window_get_message_bus
|
||||||
|
gedit_window_get_state
|
||||||
|
<SUBSECTION Standard>
|
||||||
|
GEDIT_WINDOW
|
||||||
|
GEDIT_IS_WINDOW
|
||||||
|
GEDIT_TYPE_WINDOW
|
||||||
|
gedit_window_get_type
|
||||||
|
GEDIT_WINDOW_CLASS
|
||||||
|
GEDIT_IS_WINDOW_CLASS
|
||||||
|
GEDIT_WINDOW_GET_CLASS
|
||||||
|
GEDIT_TYPE_WINDOW_STATE
|
||||||
|
GeditWindowPrivate
|
||||||
|
gedit_window_state_get_type
|
||||||
|
</SECTION>
|
||||||
|
|
||||||
|
<SECTION>
|
||||||
|
<FILE>gedit-window-activatable</FILE>
|
||||||
|
<TITLE>GeditWindowActivatable</TITLE>
|
||||||
|
GeditWindowActivatable
|
||||||
|
gedit_window_activatable_activate
|
||||||
|
gedit_window_activatable_deactivate
|
||||||
|
gedit_window_activatable_update_state
|
||||||
|
<SUBSECTION Standard>
|
||||||
|
GEDIT_TYPE_WINDOW_ACTIVATABLE
|
||||||
|
GEDIT_WINDOW_ACTIVATABLE
|
||||||
|
GEDIT_WINDOW_ACTIVATABLE_IFACE
|
||||||
|
GEDIT_IS_WINDOW_ACTIVATABLE
|
||||||
|
GEDIT_WINDOW_ACTIVATABLE_GET_IFACE
|
||||||
|
gedit_window_activatable_get_type
|
||||||
|
</SECTION>
|
||||||
|
|
||||||
|
<SECTION>
|
||||||
|
<FILE>gedit-debug</FILE>
|
||||||
|
GeditDebugSection
|
||||||
|
DEBUG_PREFS
|
||||||
|
DEBUG_WINDOW
|
||||||
|
DEBUG_PANEL
|
||||||
|
DEBUG_PLUGINS
|
||||||
|
DEBUG_TAB
|
||||||
|
DEBUG_DOCUMENT
|
||||||
|
DEBUG_COMMANDS
|
||||||
|
DEBUG_APP
|
||||||
|
DEBUG_UTILS
|
||||||
|
gedit_debug_init
|
||||||
|
gedit_debug
|
||||||
|
gedit_debug_message
|
||||||
|
gedit_debug_plugin_message
|
||||||
|
<SUBSECTION Standard>
|
||||||
|
GEDIT_TYPE_DEBUG_SECTION
|
||||||
|
gedit_debug_section_get_type
|
||||||
|
</SECTION>
|
||||||
|
|
||||||
|
<SECTION>
|
||||||
|
<FILE>gedit-menu-extension</FILE>
|
||||||
|
GeditMenuExtension
|
||||||
|
gedit_menu_extension_new
|
||||||
|
gedit_menu_extension_append_menu_item
|
||||||
|
gedit_menu_extension_prepend_menu_item
|
||||||
|
gedit_menu_extension_remove_items
|
||||||
|
<SUBSECTION Standard>
|
||||||
|
GEDIT_IS_MENU_EXTENSION
|
||||||
|
GEDIT_IS_MENU_EXTENSION_CLASS
|
||||||
|
GEDIT_MENU_EXTENSION
|
||||||
|
GEDIT_MENU_EXTENSION_CLASS
|
||||||
|
GEDIT_MENU_EXTENSION_CONST
|
||||||
|
GEDIT_MENU_EXTENSION_GET_CLASS
|
||||||
|
GEDIT_TYPE_MENU_EXTENSION
|
||||||
|
GeditMenuExtensionClass
|
||||||
|
gedit_menu_extension_get_type
|
||||||
|
</SECTION>
|
||||||
|
|
||||||
|
<SECTION>
|
||||||
|
<FILE>gedit-utils</FILE>
|
||||||
|
gedit_utils_menu_position_under_tree_view
|
||||||
|
gedit_utils_basename_for_display
|
||||||
|
gedit_utils_drop_get_uris
|
||||||
|
gedit_utils_get_compression_type_from_content_type
|
||||||
|
gedit_utils_is_valid_location
|
||||||
|
gedit_utils_set_direct_save_filename
|
||||||
|
gedit_utils_newline_type_to_string
|
||||||
|
</SECTION>
|
42
docs/reference/meson.build
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
html_dir = get_option('prefix') / gnome.gtkdoc_html_dir('gedit')
|
||||||
|
|
||||||
|
glib_docpath = dependency('glib-2.0').get_variable(pkgconfig: 'prefix') / 'share/gtk-doc/html/glib'
|
||||||
|
gobject_docpath = dependency('gobject-2.0').get_variable(pkgconfig: 'prefix') / 'share/gtk-doc/html/gobject'
|
||||||
|
gio_docpath = dependency('gio-2.0').get_variable(pkgconfig: 'prefix') / 'share/gtk-doc/html/gio'
|
||||||
|
gdk_docpath = dependency('gdk-3.0').get_variable(pkgconfig: 'prefix') / 'share/gtk-doc/html/gdk3'
|
||||||
|
gtk_docpath = dependency('gtk+-3.0').get_variable(pkgconfig: 'prefix') / 'share/gtk-doc/html/gtk3'
|
||||||
|
gsv_docpath = dependency('libgedit-gtksourceview-300').get_variable(pkgconfig: 'prefix') / 'share/gtk-doc/html/libgedit-gtksourceview-300'
|
||||||
|
amtk_docpath = dependency('libgedit-amtk-5').get_variable(pkgconfig: 'prefix') / 'share/gtk-doc/html/libgedit-amtk-5'
|
||||||
|
tepl_docpath = dependency('libgedit-tepl-6').get_variable(pkgconfig: 'prefix') / 'share/gtk-doc/html/libgedit-tepl-6'
|
||||||
|
libpeas_docpath = dependency('libpeas-1.0').get_variable(pkgconfig: 'prefix') / 'share/gtk-doc/html/libpeas'
|
||||||
|
|
||||||
|
gedit_doc_dep = declare_dependency(
|
||||||
|
link_with: libgedit_shared_lib,
|
||||||
|
include_directories: root_include_dir,
|
||||||
|
dependencies: deps_basic_list,
|
||||||
|
)
|
||||||
|
|
||||||
|
gnome.gtkdoc(
|
||||||
|
'gedit',
|
||||||
|
main_xml: 'gedit-docs.xml',
|
||||||
|
src_dir: include_directories('../../gedit/'),
|
||||||
|
dependencies: gedit_doc_dep,
|
||||||
|
scan_args: ['--rebuild-types'],
|
||||||
|
fixxref_args: [
|
||||||
|
'--html-dir=@0@'.format(html_dir),
|
||||||
|
'--extra-dir=@0@'.format(glib_docpath),
|
||||||
|
'--extra-dir=@0@'.format(gobject_docpath),
|
||||||
|
'--extra-dir=@0@'.format(gio_docpath),
|
||||||
|
'--extra-dir=@0@'.format(gdk_docpath),
|
||||||
|
'--extra-dir=@0@'.format(gtk_docpath),
|
||||||
|
'--extra-dir=@0@'.format(gsv_docpath),
|
||||||
|
'--extra-dir=@0@'.format(amtk_docpath),
|
||||||
|
'--extra-dir=@0@'.format(tepl_docpath),
|
||||||
|
'--extra-dir=@0@'.format(libpeas_docpath),
|
||||||
|
],
|
||||||
|
content_files: [
|
||||||
|
'api-breaks.xml'
|
||||||
|
],
|
||||||
|
ignore_headers: libgedit_private_headers,
|
||||||
|
install: true,
|
||||||
|
)
|
68
docs/roadmap.md
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
gedit roadmap
|
||||||
|
=============
|
||||||
|
|
||||||
|
This page contains the plans for major code changes we hope to get done in the
|
||||||
|
future.
|
||||||
|
|
||||||
|
Take care and fix the common bugs
|
||||||
|
---------------------------------
|
||||||
|
|
||||||
|
Status: **in progress**
|
||||||
|
|
||||||
|
See the list in the [common-bugs.md](common-bugs.md) file.
|
||||||
|
|
||||||
|
Continue to make the gedit source code more re-usable
|
||||||
|
-----------------------------------------------------
|
||||||
|
|
||||||
|
Status: **in progress** (this is an ongoing effort)
|
||||||
|
|
||||||
|
Develop and use the [Gedit Technology](https://gedit-technology.github.io/) set
|
||||||
|
of libraries.
|
||||||
|
|
||||||
|
Rework the search & replace UI
|
||||||
|
------------------------------
|
||||||
|
|
||||||
|
Status: **todo**
|
||||||
|
|
||||||
|
Have an horizontal bar, to not occlude the text.
|
||||||
|
|
||||||
|
Be able to quit the application with all documents saved, and restored on next start
|
||||||
|
------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Status: **todo**
|
||||||
|
|
||||||
|
Even for unsaved and untitled files, be able to quit gedit, restart it later and
|
||||||
|
come back to the previous state with all tabs restored.
|
||||||
|
|
||||||
|
Improve the workflow for printing to paper
|
||||||
|
------------------------------------------
|
||||||
|
|
||||||
|
Status: **todo**
|
||||||
|
|
||||||
|
Show first a preview of the file to print and do the configuration from there.
|
||||||
|
|
||||||
|
Use native file chooser dialog windows (GtkFileChooserNative)
|
||||||
|
-------------------------------------------------------------
|
||||||
|
|
||||||
|
Status: **todo**
|
||||||
|
|
||||||
|
To have the native file chooser on MS Windows, and use the Flatpak portal.
|
||||||
|
|
||||||
|
This task requires to rework the file loading and saving code. To have a
|
||||||
|
different - but still user-friendly - way to choose the character encoding and
|
||||||
|
line ending type.
|
||||||
|
|
||||||
|
Avoid the need for gedit forks
|
||||||
|
------------------------------
|
||||||
|
|
||||||
|
Status: **todo**
|
||||||
|
|
||||||
|
There are several forks of gedit available: [Pluma](https://github.com/mate-desktop/pluma)
|
||||||
|
(from the MATE desktop environment) and [xed](https://github.com/linuxmint/xed)
|
||||||
|
(from the Linux Mint distribution). xed is a fork of Pluma, and Pluma is a fork
|
||||||
|
of gedit.
|
||||||
|
|
||||||
|
The goal is to make gedit suitable for MATE and Linux Mint. This can be
|
||||||
|
implemented by adding a “gedit-classic” configuration option. Or implement it
|
||||||
|
similarly to LibreOffice, to give the user a choice between several UI
|
||||||
|
paradigms.
|
79
gedit.doap
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Project xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
|
||||||
|
xmlns:foaf="http://xmlns.com/foaf/0.1/"
|
||||||
|
xmlns:gnome="http://api.gnome.org/doap-extensions#"
|
||||||
|
xmlns="http://usefulinc.com/ns/doap#">
|
||||||
|
|
||||||
|
<name>gedit</name>
|
||||||
|
<shortdesc xml:lang="en">gedit, a text editor</shortdesc>
|
||||||
|
<description xml:lang="en">
|
||||||
|
gedit is an easy-to-use and general-purpose text editor. Its development started
|
||||||
|
in 1998, at the beginnings of the GNOME project, with a good integration with
|
||||||
|
that desktop environment.
|
||||||
|
|
||||||
|
You can use it to write simple notes and documents, or you can enable more
|
||||||
|
advanced features that are useful for software development.
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<homepage rdf:resource="https://gedit-technology.github.io/apps/gedit/" />
|
||||||
|
<support-forum rdf:resource="https://discourse.gnome.org/tag/gedit" />
|
||||||
|
<download-page rdf:resource="http://download.gnome.org/sources/gedit/" />
|
||||||
|
<bug-database rdf:resource="https://gitlab.gnome.org/World/gedit/gedit/-/issues/" />
|
||||||
|
|
||||||
|
<programming-language>C</programming-language>
|
||||||
|
<programming-language>Python</programming-language>
|
||||||
|
|
||||||
|
<maintainer>
|
||||||
|
<foaf:Person>
|
||||||
|
<foaf:name>Sébastien Wilmet</foaf:name>
|
||||||
|
<foaf:mbox rdf:resource="mailto:swilmet@mailfence.com" />
|
||||||
|
<gnome:userid>swilmet</gnome:userid>
|
||||||
|
</foaf:Person>
|
||||||
|
</maintainer>
|
||||||
|
|
||||||
|
<!-- Former maintainers
|
||||||
|
<maintainer>
|
||||||
|
<foaf:Person>
|
||||||
|
<foaf:name>Paolo Maggi</foaf:name>
|
||||||
|
<foaf:mbox rdf:resource="mailto:paolo@gnome.org" />
|
||||||
|
<gnome:userid>paolo</gnome:userid>
|
||||||
|
</foaf:Person>
|
||||||
|
</maintainer>
|
||||||
|
<maintainer>
|
||||||
|
<foaf:Person>
|
||||||
|
<foaf:name>Paolo Borelli</foaf:name>
|
||||||
|
<foaf:mbox rdf:resource="mailto:pborelli@gnome.org" />
|
||||||
|
<gnome:userid>pborelli</gnome:userid>
|
||||||
|
</foaf:Person>
|
||||||
|
</maintainer>
|
||||||
|
<maintainer>
|
||||||
|
<foaf:Person>
|
||||||
|
<foaf:name>Jesse van den Kieboom</foaf:name>
|
||||||
|
<foaf:mbox rdf:resource="mailto:jessevdk@gnome.org" />
|
||||||
|
<gnome:userid>jessevdk</gnome:userid>
|
||||||
|
</foaf:Person>
|
||||||
|
</maintainer>
|
||||||
|
<maintainer>
|
||||||
|
<foaf:Person>
|
||||||
|
<foaf:name>Ignacio Casal Quinteiro</foaf:name>
|
||||||
|
<foaf:mbox rdf:resource="mailto:icq@gnome.org" />
|
||||||
|
<gnome:userid>icq</gnome:userid>
|
||||||
|
</foaf:Person>
|
||||||
|
</maintainer>
|
||||||
|
<maintainer>
|
||||||
|
<foaf:Person>
|
||||||
|
<foaf:name>Jordi Mas</foaf:name>
|
||||||
|
<foaf:mbox rdf:resource="mailto:jmas@softcatala.org" />
|
||||||
|
<gnome:userid>jmas</gnome:userid>
|
||||||
|
</foaf:Person>
|
||||||
|
</maintainer>
|
||||||
|
<maintainer>
|
||||||
|
<foaf:Person>
|
||||||
|
<foaf:name>Jeremy Bicha</foaf:name>
|
||||||
|
<foaf:mbox rdf:resource="mailto:jbicha@ubuntu.com" />
|
||||||
|
<gnome:userid>jbicha</gnome:userid>
|
||||||
|
</foaf:Person>
|
||||||
|
</maintainer>
|
||||||
|
-->
|
||||||
|
</Project>
|
99
gedit/Gedit.py
Normal file
|
@ -0,0 +1,99 @@
|
||||||
|
# Copyright (C) 2011 Jesse van den Kieboom <jesse@icecrew.nl>
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
from gi.repository import GObject
|
||||||
|
import inspect
|
||||||
|
|
||||||
|
from ..overrides import override
|
||||||
|
from ..importer import modules
|
||||||
|
|
||||||
|
Gedit = modules['Gedit']._introspection_module
|
||||||
|
__all__ = []
|
||||||
|
|
||||||
|
class MessageBus(Gedit.MessageBus):
|
||||||
|
def create(self, object_path, method, **kwargs):
|
||||||
|
tp = self.lookup(object_path, method)
|
||||||
|
|
||||||
|
if not tp.is_a(Gedit.Message.__gtype__):
|
||||||
|
return None
|
||||||
|
|
||||||
|
kwargs['object-path'] = object_path
|
||||||
|
kwargs['method'] = method
|
||||||
|
|
||||||
|
return GObject.new(tp, **kwargs)
|
||||||
|
|
||||||
|
def send_sync(self, object_path, method, **kwargs):
|
||||||
|
msg = self.create(object_path, method, **kwargs)
|
||||||
|
self.send_message_sync(msg)
|
||||||
|
|
||||||
|
return msg
|
||||||
|
|
||||||
|
def send(self, object_path, method, **kwargs):
|
||||||
|
msg = self.create(object_path, method, **kwargs)
|
||||||
|
self.send_message(msg)
|
||||||
|
|
||||||
|
return msg
|
||||||
|
|
||||||
|
MessageBus = override(MessageBus)
|
||||||
|
__all__.append('MessageBus')
|
||||||
|
|
||||||
|
class Message(Gedit.Message):
|
||||||
|
def __getattribute__(self, name):
|
||||||
|
try:
|
||||||
|
return Gedit.Message.__getattribute__(self, name)
|
||||||
|
except:
|
||||||
|
return getattr(self.props, name)
|
||||||
|
|
||||||
|
Message = override(Message)
|
||||||
|
__all__.append('Message')
|
||||||
|
|
||||||
|
|
||||||
|
def get_trace_info(num_back_frames=0):
|
||||||
|
frame = inspect.currentframe().f_back
|
||||||
|
try:
|
||||||
|
for i in range(num_back_frames):
|
||||||
|
back_frame = frame.f_back
|
||||||
|
if back_frame is None:
|
||||||
|
break
|
||||||
|
frame = back_frame
|
||||||
|
|
||||||
|
filename = frame.f_code.co_filename
|
||||||
|
|
||||||
|
# http://code.activestate.com/recipes/145297-grabbing-the-current-line-number-easily/
|
||||||
|
lineno = frame.f_lineno
|
||||||
|
|
||||||
|
func_name = frame.f_code.co_name
|
||||||
|
try:
|
||||||
|
# http://stackoverflow.com/questions/2203424/python-how-to-retrieve-class-information-from-a-frame-object
|
||||||
|
cls_name = frame.f_locals["self"].__class__.__name__
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
func_name = "%s.%s" % (cls_name, func_name)
|
||||||
|
|
||||||
|
return (filename, lineno, func_name)
|
||||||
|
finally:
|
||||||
|
frame = None
|
||||||
|
|
||||||
|
orig_debug_plugin_message_func = Gedit.debug_plugin_message
|
||||||
|
|
||||||
|
@override(Gedit.debug_plugin_message)
|
||||||
|
def debug_plugin_message(format, *format_args):
|
||||||
|
filename, lineno, func_name = get_trace_info(1)
|
||||||
|
orig_debug_plugin_message_func(filename, lineno, func_name, format % format_args)
|
||||||
|
__all__.append(debug_plugin_message)
|
||||||
|
|
||||||
|
# vi:ex:ts=4:et
|
117
gedit/gedit-app-activatable.c
Normal file
|
@ -0,0 +1,117 @@
|
||||||
|
/*
|
||||||
|
* gedit-app-activatable.h
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Steve Frécinaux
|
||||||
|
* Copyright (C) 2010 Jesse van den Kieboom
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Library General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "gedit-app-activatable.h"
|
||||||
|
#include "gedit-app.h"
|
||||||
|
#include "gedit-app-private.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SECTION:gedit-app-activatable
|
||||||
|
* @short_description: Interface for activatable extensions on apps
|
||||||
|
* @see_also: #PeasExtensionSet
|
||||||
|
*
|
||||||
|
* #GeditAppActivatable is an interface which should be implemented by
|
||||||
|
* extensions that should be activated on a gedit application.
|
||||||
|
**/
|
||||||
|
|
||||||
|
G_DEFINE_INTERFACE(GeditAppActivatable, gedit_app_activatable, G_TYPE_OBJECT)
|
||||||
|
|
||||||
|
static void
|
||||||
|
gedit_app_activatable_default_init (GeditAppActivatableInterface *iface)
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* GeditAppActivatable:app:
|
||||||
|
*
|
||||||
|
* The app property contains the gedit app for this
|
||||||
|
* #GeditAppActivatable instance.
|
||||||
|
*/
|
||||||
|
g_object_interface_install_property (iface,
|
||||||
|
g_param_spec_object ("app",
|
||||||
|
"App",
|
||||||
|
"The gedit app",
|
||||||
|
GEDIT_TYPE_APP,
|
||||||
|
G_PARAM_READWRITE |
|
||||||
|
G_PARAM_CONSTRUCT_ONLY |
|
||||||
|
G_PARAM_STATIC_STRINGS));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gedit_app_activatable_activate:
|
||||||
|
* @activatable: A #GeditAppActivatable.
|
||||||
|
*
|
||||||
|
* Activates the extension on the application.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gedit_app_activatable_activate (GeditAppActivatable *activatable)
|
||||||
|
{
|
||||||
|
GeditAppActivatableInterface *iface;
|
||||||
|
|
||||||
|
g_return_if_fail (GEDIT_IS_APP_ACTIVATABLE (activatable));
|
||||||
|
|
||||||
|
iface = GEDIT_APP_ACTIVATABLE_GET_IFACE (activatable);
|
||||||
|
|
||||||
|
if (iface->activate != NULL)
|
||||||
|
{
|
||||||
|
iface->activate (activatable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gedit_app_activatable_deactivate:
|
||||||
|
* @activatable: A #GeditAppActivatable.
|
||||||
|
*
|
||||||
|
* Deactivates the extension from the application.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gedit_app_activatable_deactivate (GeditAppActivatable *activatable)
|
||||||
|
{
|
||||||
|
GeditAppActivatableInterface *iface;
|
||||||
|
|
||||||
|
g_return_if_fail (GEDIT_IS_APP_ACTIVATABLE (activatable));
|
||||||
|
|
||||||
|
iface = GEDIT_APP_ACTIVATABLE_GET_IFACE (activatable);
|
||||||
|
|
||||||
|
if (iface->deactivate != NULL)
|
||||||
|
{
|
||||||
|
iface->deactivate (activatable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GeditMenuExtension *
|
||||||
|
gedit_app_activatable_extend_menu (GeditAppActivatable *activatable,
|
||||||
|
const gchar *extension_point)
|
||||||
|
{
|
||||||
|
GeditApp *app;
|
||||||
|
GeditMenuExtension *ext;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GEDIT_IS_APP_ACTIVATABLE (activatable), NULL);
|
||||||
|
|
||||||
|
g_object_get (G_OBJECT (activatable), "app", &app, NULL);
|
||||||
|
ext = _gedit_app_extend_menu (app, extension_point);
|
||||||
|
g_object_unref (app);
|
||||||
|
|
||||||
|
return ext;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ex:set ts=8 noet: */
|
64
gedit/gedit-app-activatable.h
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
/*
|
||||||
|
* gedit-app-activatable.h
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 - Steve Frécinaux
|
||||||
|
* Copyright (C) 2010 - Jesse van den Kieboom
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Library General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GEDIT_APP_ACTIVATABLE_H
|
||||||
|
#define GEDIT_APP_ACTIVATABLE_H
|
||||||
|
|
||||||
|
#include <glib-object.h>
|
||||||
|
#include <gedit/gedit-menu-extension.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define GEDIT_TYPE_APP_ACTIVATABLE (gedit_app_activatable_get_type ())
|
||||||
|
|
||||||
|
G_DECLARE_INTERFACE (GeditAppActivatable, gedit_app_activatable, GEDIT, APP_ACTIVATABLE, GObject)
|
||||||
|
|
||||||
|
struct _GeditAppActivatableInterface
|
||||||
|
{
|
||||||
|
GTypeInterface g_iface;
|
||||||
|
|
||||||
|
/* Virtual public methods */
|
||||||
|
void (*activate) (GeditAppActivatable *activatable);
|
||||||
|
void (*deactivate) (GeditAppActivatable *activatable);
|
||||||
|
};
|
||||||
|
|
||||||
|
void gedit_app_activatable_activate (GeditAppActivatable *activatable);
|
||||||
|
void gedit_app_activatable_deactivate (GeditAppActivatable *activatable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gedit_app_activatable_extend_menu:
|
||||||
|
* @activatable: A #GeditAppActivatable.
|
||||||
|
* @extension_point: the extension point section of the menu to get.
|
||||||
|
*
|
||||||
|
* Gets the #GeditMenuExtension for the menu @extension_point. Note that
|
||||||
|
* the extension point could be in different menus (gear menu, app menu, etc)
|
||||||
|
* depending on the platform.
|
||||||
|
*
|
||||||
|
* Returns: (transfer full): a #GeditMenuExtension for the specific section
|
||||||
|
* or %NULL if not found.
|
||||||
|
*/
|
||||||
|
GeditMenuExtension *gedit_app_activatable_extend_menu (GeditAppActivatable *activatable,
|
||||||
|
const gchar *extension_point);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* GEDIT_APP_ACTIVATABLE_H */
|
||||||
|
/* ex:set ts=8 noet: */
|
41
gedit/gedit-app-osx.h
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
* gedit-app-osx.h
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 - Jesse van den Kieboom
|
||||||
|
*
|
||||||
|
* gedit is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* gedit is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with gedit; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||||
|
* Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GEDIT_APP_OSX_H
|
||||||
|
#define GEDIT_APP_OSX_H
|
||||||
|
|
||||||
|
#include "gedit-app.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define GEDIT_TYPE_APP_OSX (gedit_app_osx_get_type ())
|
||||||
|
|
||||||
|
G_DECLARE_FINAL_TYPE (GeditAppOSX, gedit_app_osx, GEDIT, APP_OSX, GeditApp)
|
||||||
|
|
||||||
|
gboolean gedit_app_osx_show_url (GeditAppOSX *app,
|
||||||
|
const gchar *url);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* GEDIT_APP_OSX_H */
|
||||||
|
|
||||||
|
/* ex:set ts=8 noet: */
|
601
gedit/gedit-app-osx.m
Normal file
|
@ -0,0 +1,601 @@
|
||||||
|
/*
|
||||||
|
* gedit-app-osx.c
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 - Jesse van den Kieboom
|
||||||
|
*
|
||||||
|
* gedit is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* gedit is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with gedit; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||||
|
* Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "gedit-app-osx.h"
|
||||||
|
|
||||||
|
#include <gdk/gdkquartz.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <glib/gi18n.h>
|
||||||
|
|
||||||
|
#include "gedit-app-private.h"
|
||||||
|
#include "gedit-dirs.h"
|
||||||
|
#include "gedit-debug.h"
|
||||||
|
#include "gedit-commands.h"
|
||||||
|
#include "gedit-commands-private.h"
|
||||||
|
#include "gedit-document-private.h"
|
||||||
|
#include "gedit-recent-osx.h"
|
||||||
|
#import <AppKit/AppKit.h>
|
||||||
|
|
||||||
|
NSWindow *gdk_quartz_window_get_nswindow(GdkWindow *window);
|
||||||
|
NSEvent *gdk_quartz_event_get_nsevent(GdkEvent *event);
|
||||||
|
|
||||||
|
static GeditWindow *
|
||||||
|
ensure_window (GeditAppOSX *app,
|
||||||
|
gboolean with_empty_document)
|
||||||
|
{
|
||||||
|
GList *windows;
|
||||||
|
GeditWindow *ret = NULL;
|
||||||
|
|
||||||
|
windows = gtk_application_get_windows (GTK_APPLICATION (app));
|
||||||
|
|
||||||
|
while (windows)
|
||||||
|
{
|
||||||
|
GtkWindow *window;
|
||||||
|
GdkWindow *win;
|
||||||
|
NSWindow *nswin;
|
||||||
|
|
||||||
|
window = windows->data;
|
||||||
|
windows = g_list_next (windows);
|
||||||
|
|
||||||
|
if (!gtk_widget_get_realized (GTK_WIDGET (window)))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!GEDIT_IS_WINDOW (window))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
win = gtk_widget_get_window (GTK_WIDGET (window));
|
||||||
|
nswin = gdk_quartz_window_get_nswindow (win);
|
||||||
|
|
||||||
|
if ([nswin isOnActiveSpace])
|
||||||
|
{
|
||||||
|
ret = GEDIT_WINDOW (window);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ret)
|
||||||
|
{
|
||||||
|
ret = gedit_app_create_window (GEDIT_APP (app), NULL);
|
||||||
|
gtk_widget_show (GTK_WIDGET (ret));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (with_empty_document && gedit_window_get_active_document (ret) == NULL)
|
||||||
|
{
|
||||||
|
gedit_window_create_tab (ret, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_window_present (GTK_WINDOW (ret));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@interface GeditAppOSXDelegate : NSObject
|
||||||
|
{
|
||||||
|
GeditAppOSX *app;
|
||||||
|
id<NSApplicationDelegate> orig;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id)initWithApp:(GeditAppOSX *)theApp;
|
||||||
|
- (void)release;
|
||||||
|
|
||||||
|
- (id)forwardingTargetForSelector:(SEL)aSelector;
|
||||||
|
- (BOOL)respondsToSelector:(SEL)aSelector;
|
||||||
|
|
||||||
|
- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag;
|
||||||
|
- (void)applicationWillBecomeActive:(NSNotification *)aNotification;
|
||||||
|
- (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation GeditAppOSXDelegate
|
||||||
|
- (id)initWithApp:(GeditAppOSX *)theApp
|
||||||
|
{
|
||||||
|
[super init];
|
||||||
|
app = theApp;
|
||||||
|
|
||||||
|
orig = [NSApp delegate];
|
||||||
|
[NSApp setDelegate:self];
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)release
|
||||||
|
{
|
||||||
|
[NSApp setDelegate:orig];
|
||||||
|
[super release];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id)forwardingTargetForSelector:(SEL)aSelector
|
||||||
|
{
|
||||||
|
return orig;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)respondsToSelector:(SEL)aSelector
|
||||||
|
{
|
||||||
|
return [super respondsToSelector:aSelector] || [orig respondsToSelector:aSelector];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag
|
||||||
|
{
|
||||||
|
ensure_window (app, TRUE);
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)applicationWillBecomeActive:(NSNotification *)aNotification
|
||||||
|
{
|
||||||
|
ensure_window (app, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames
|
||||||
|
{
|
||||||
|
ensure_window (app, FALSE);
|
||||||
|
[orig application:sender openFiles:filenames];
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
struct _GeditAppOSX
|
||||||
|
{
|
||||||
|
GeditApp parent_instance;
|
||||||
|
|
||||||
|
GeditMenuExtension *recent_files_menu;
|
||||||
|
gulong recent_manager_changed_id;
|
||||||
|
|
||||||
|
GeditAppOSXDelegate *app_delegate;
|
||||||
|
|
||||||
|
GList *recent_actions;
|
||||||
|
GeditRecentConfiguration recent_config;
|
||||||
|
};
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (GeditAppOSX, gedit_app_osx, GEDIT_TYPE_APP)
|
||||||
|
|
||||||
|
static void
|
||||||
|
remove_recent_actions (GeditAppOSX *app)
|
||||||
|
{
|
||||||
|
while (app->recent_actions)
|
||||||
|
{
|
||||||
|
gchar *action_name = app->recent_actions->data;
|
||||||
|
|
||||||
|
g_action_map_remove_action (G_ACTION_MAP (app), action_name);
|
||||||
|
g_free (action_name);
|
||||||
|
|
||||||
|
app->recent_actions = g_list_delete_link (app->recent_actions,
|
||||||
|
app->recent_actions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gedit_app_osx_finalize (GObject *object)
|
||||||
|
{
|
||||||
|
GeditAppOSX *app = GEDIT_APP_OSX (object);
|
||||||
|
|
||||||
|
g_object_unref (app->recent_files_menu);
|
||||||
|
|
||||||
|
remove_recent_actions (app);
|
||||||
|
|
||||||
|
g_signal_handler_disconnect (app->recent_config.manager,
|
||||||
|
app->recent_manager_changed_id);
|
||||||
|
|
||||||
|
gedit_recent_configuration_destroy (&app->recent_config);
|
||||||
|
|
||||||
|
[app->app_delegate release];
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (gedit_app_osx_parent_class)->finalize (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gedit_app_osx_show_url (GeditAppOSX *app,
|
||||||
|
const gchar *url)
|
||||||
|
{
|
||||||
|
return [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:[NSString stringWithUTF8String:url]]];
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gedit_app_osx_show_help_impl (GeditApp *app,
|
||||||
|
GtkWindow *parent,
|
||||||
|
const gchar *name,
|
||||||
|
const gchar *link_id)
|
||||||
|
{
|
||||||
|
gboolean ret = FALSE;
|
||||||
|
|
||||||
|
if (name == NULL || g_strcmp0 (name, "gedit") == 0)
|
||||||
|
{
|
||||||
|
gchar *link;
|
||||||
|
|
||||||
|
if (link_id)
|
||||||
|
{
|
||||||
|
link = g_strdup_printf ("https://gedit-technology.github.io/user-manuals/gedit/%s",
|
||||||
|
link_id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
link = g_strdup ("https://gedit-technology.github.io/user-manuals/gedit/");
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = gedit_app_osx_show_url (GEDIT_APP_OSX (app), link);
|
||||||
|
g_free (link);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gedit_app_osx_set_window_title_impl (GeditApp *app,
|
||||||
|
GeditWindow *window,
|
||||||
|
const gchar *title)
|
||||||
|
{
|
||||||
|
NSWindow *native;
|
||||||
|
GeditDocument *document;
|
||||||
|
GdkWindow *wnd;
|
||||||
|
|
||||||
|
g_return_if_fail (GEDIT_IS_WINDOW (window));
|
||||||
|
|
||||||
|
wnd = gtk_widget_get_window (GTK_WIDGET (window));
|
||||||
|
|
||||||
|
if (wnd == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
native = gdk_quartz_window_get_nswindow (wnd);
|
||||||
|
document = gedit_window_get_active_document (window);
|
||||||
|
|
||||||
|
if (document)
|
||||||
|
{
|
||||||
|
bool ismodified;
|
||||||
|
|
||||||
|
if (_gedit_document_is_untitled (document))
|
||||||
|
{
|
||||||
|
[native setRepresentedURL:nil];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GtkSourceFile *file;
|
||||||
|
GFile *location;
|
||||||
|
gchar *uri;
|
||||||
|
|
||||||
|
file = gedit_document_get_file (document);
|
||||||
|
location = gtk_source_file_get_location (file);
|
||||||
|
|
||||||
|
uri = g_file_get_uri (location);
|
||||||
|
|
||||||
|
NSURL *nsurl = [NSURL URLWithString:[NSString stringWithUTF8String:uri]];
|
||||||
|
|
||||||
|
[native setRepresentedURL:nsurl];
|
||||||
|
g_free (uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
ismodified = !tepl_buffer_is_untouched (TEPL_BUFFER (document));
|
||||||
|
[native setDocumentEdited:ismodified];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[native setRepresentedURL:nil];
|
||||||
|
[native setDocumentEdited:false];
|
||||||
|
}
|
||||||
|
|
||||||
|
GEDIT_APP_CLASS (gedit_app_osx_parent_class)->set_window_title (app, window, title);
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
GeditAppOSX *app;
|
||||||
|
GtkRecentInfo *info;
|
||||||
|
} RecentFileInfo;
|
||||||
|
|
||||||
|
static void
|
||||||
|
recent_file_info_free (gpointer data,
|
||||||
|
GClosure *closure)
|
||||||
|
{
|
||||||
|
RecentFileInfo *info = data;
|
||||||
|
|
||||||
|
g_object_unref (info->app);
|
||||||
|
gtk_recent_info_unref (info->info);
|
||||||
|
|
||||||
|
g_slice_free (RecentFileInfo, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
recent_file_activated (GAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
RecentFileInfo *info)
|
||||||
|
{
|
||||||
|
GeditWindow *window;
|
||||||
|
const gchar *uri;
|
||||||
|
GFile *file;
|
||||||
|
|
||||||
|
uri = gtk_recent_info_get_uri (info->info);
|
||||||
|
file = g_file_new_for_uri (uri);
|
||||||
|
|
||||||
|
window = ensure_window (info->app, FALSE);
|
||||||
|
|
||||||
|
gedit_commands_load_location (GEDIT_WINDOW (window), file, NULL, 0, 0);
|
||||||
|
g_object_unref (file);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
recent_files_menu_populate (GeditAppOSX *app)
|
||||||
|
{
|
||||||
|
GList *items;
|
||||||
|
gint i = 0;
|
||||||
|
|
||||||
|
gedit_menu_extension_remove_items (app->recent_files_menu);
|
||||||
|
remove_recent_actions (app);
|
||||||
|
|
||||||
|
items = gedit_recent_get_items (&app->recent_config);
|
||||||
|
|
||||||
|
while (items)
|
||||||
|
{
|
||||||
|
GtkRecentInfo *info = items->data;
|
||||||
|
GMenuItem *mitem;
|
||||||
|
const gchar *name;
|
||||||
|
gchar *acname;
|
||||||
|
gchar *acfullname;
|
||||||
|
GSimpleAction *action;
|
||||||
|
RecentFileInfo *finfo;
|
||||||
|
|
||||||
|
name = gtk_recent_info_get_display_name (info);
|
||||||
|
|
||||||
|
acname = g_strdup_printf ("recent-file-action-%d", ++i);
|
||||||
|
action = g_simple_action_new (acname, NULL);
|
||||||
|
|
||||||
|
finfo = g_slice_new (RecentFileInfo);
|
||||||
|
finfo->app = g_object_ref (app);
|
||||||
|
finfo->info = gtk_recent_info_ref (info);
|
||||||
|
|
||||||
|
g_signal_connect_data (action,
|
||||||
|
"activate",
|
||||||
|
G_CALLBACK (recent_file_activated),
|
||||||
|
finfo,
|
||||||
|
recent_file_info_free,
|
||||||
|
0);
|
||||||
|
|
||||||
|
g_action_map_add_action (G_ACTION_MAP (app), G_ACTION (action));
|
||||||
|
g_object_unref (action);
|
||||||
|
|
||||||
|
acfullname = g_strdup_printf ("app.%s", acname);
|
||||||
|
|
||||||
|
app->recent_actions = g_list_prepend (app->recent_actions, acname);
|
||||||
|
|
||||||
|
mitem = g_menu_item_new (name, acfullname);
|
||||||
|
gedit_menu_extension_append_menu_item (app->recent_files_menu, mitem);
|
||||||
|
|
||||||
|
g_free (acfullname);
|
||||||
|
|
||||||
|
g_object_unref (mitem);
|
||||||
|
gtk_recent_info_unref (info);
|
||||||
|
|
||||||
|
items = g_list_delete_link (items, items);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
recent_manager_changed (GtkRecentManager *manager,
|
||||||
|
GeditAppOSX *app)
|
||||||
|
{
|
||||||
|
recent_files_menu_populate (app);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
open_activated (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer userdata)
|
||||||
|
{
|
||||||
|
_gedit_cmd_file_open (NULL, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static GActionEntry app_entries[] = {
|
||||||
|
{ "open", open_activated, NULL, NULL, NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
update_open_sensitivity (GeditAppOSX *app)
|
||||||
|
{
|
||||||
|
GAction *action;
|
||||||
|
gboolean has_windows;
|
||||||
|
|
||||||
|
has_windows = (gtk_application_get_windows (GTK_APPLICATION (app)) != NULL);
|
||||||
|
|
||||||
|
action = g_action_map_lookup_action (G_ACTION_MAP (app), "open");
|
||||||
|
g_simple_action_set_enabled (G_SIMPLE_ACTION (action), !has_windows);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gedit_app_osx_startup (GApplication *application)
|
||||||
|
{
|
||||||
|
const gchar *replace_accels[] = {
|
||||||
|
"<Primary><Alt>F",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
const gchar *open_accels[] = {
|
||||||
|
"<Primary>O",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
const gchar *fullscreen_accels[] = {
|
||||||
|
"<Primary><Control>F",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
GeditAppOSX *app = GEDIT_APP_OSX (application);
|
||||||
|
|
||||||
|
G_APPLICATION_CLASS (gedit_app_osx_parent_class)->startup (application);
|
||||||
|
|
||||||
|
app->app_delegate = [[[GeditAppOSXDelegate alloc] initWithApp:app] retain];
|
||||||
|
|
||||||
|
g_action_map_add_action_entries (G_ACTION_MAP (application),
|
||||||
|
app_entries,
|
||||||
|
G_N_ELEMENTS (app_entries),
|
||||||
|
application);
|
||||||
|
|
||||||
|
gtk_application_set_accels_for_action (GTK_APPLICATION (application),
|
||||||
|
"win.replace",
|
||||||
|
replace_accels);
|
||||||
|
|
||||||
|
gtk_application_set_accels_for_action (GTK_APPLICATION (application),
|
||||||
|
"app.open",
|
||||||
|
open_accels);
|
||||||
|
|
||||||
|
gtk_application_set_accels_for_action (GTK_APPLICATION (application),
|
||||||
|
"win.fullscreen",
|
||||||
|
fullscreen_accels);
|
||||||
|
|
||||||
|
gedit_recent_configuration_init_default (&app->recent_config);
|
||||||
|
|
||||||
|
app->recent_files_menu = _gedit_app_extend_menu (GEDIT_APP (application),
|
||||||
|
"recent-files-section");
|
||||||
|
|
||||||
|
app->recent_manager_changed_id = g_signal_connect (app->recent_config.manager,
|
||||||
|
"changed",
|
||||||
|
G_CALLBACK (recent_manager_changed),
|
||||||
|
app);
|
||||||
|
|
||||||
|
recent_files_menu_populate (app);
|
||||||
|
|
||||||
|
g_application_hold (application);
|
||||||
|
update_open_sensitivity (app);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
set_window_allow_fullscreen (GeditWindow *window)
|
||||||
|
{
|
||||||
|
GdkWindow *wnd;
|
||||||
|
NSWindow *native;
|
||||||
|
|
||||||
|
wnd = gtk_widget_get_window (GTK_WIDGET (window));
|
||||||
|
|
||||||
|
if (wnd != NULL)
|
||||||
|
{
|
||||||
|
native = gdk_quartz_window_get_nswindow (wnd);
|
||||||
|
[native setCollectionBehavior: [native collectionBehavior] | NSWindowCollectionBehaviorFullScreenPrimary];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_window_realized (GtkWidget *widget)
|
||||||
|
{
|
||||||
|
set_window_allow_fullscreen (GEDIT_WINDOW (widget));
|
||||||
|
}
|
||||||
|
|
||||||
|
static GeditWindow *
|
||||||
|
gedit_app_osx_create_window_impl (GeditApp *app)
|
||||||
|
{
|
||||||
|
GeditWindow *window;
|
||||||
|
|
||||||
|
window = GEDIT_APP_CLASS (gedit_app_osx_parent_class)->create_window (app);
|
||||||
|
|
||||||
|
if (gtk_widget_get_realized (GTK_WIDGET (window)))
|
||||||
|
{
|
||||||
|
set_window_allow_fullscreen (window);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_signal_connect (window, "realize", G_CALLBACK (on_window_realized), NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return window;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gedit_app_osx_process_window_event_impl (GeditApp *app,
|
||||||
|
GeditWindow *window,
|
||||||
|
GdkEvent *event)
|
||||||
|
{
|
||||||
|
NSEvent *nsevent;
|
||||||
|
|
||||||
|
/* For OS X we will propagate the event to NSApp, which handles some OS X
|
||||||
|
* specific keybindings and the accelerators for the menu
|
||||||
|
*/
|
||||||
|
nsevent = gdk_quartz_event_get_nsevent (event);
|
||||||
|
[NSApp sendEvent:nsevent];
|
||||||
|
|
||||||
|
/* It does not really matter what we return here since it's the last thing
|
||||||
|
* in the chain. Also we can't get from sendEvent whether the event was
|
||||||
|
* actually handled by NSApp anyway
|
||||||
|
*/
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gedit_app_osx_constructed (GObject *object)
|
||||||
|
{
|
||||||
|
/* FIXME: should we do this on all platforms? */
|
||||||
|
g_object_set (object, "register-session", TRUE, NULL);
|
||||||
|
G_OBJECT_CLASS (gedit_app_osx_parent_class)->constructed (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gedit_app_osx_window_added (GtkApplication *application,
|
||||||
|
GtkWindow *window)
|
||||||
|
{
|
||||||
|
GTK_APPLICATION_CLASS (gedit_app_osx_parent_class)->window_added (application, window);
|
||||||
|
|
||||||
|
update_open_sensitivity (GEDIT_APP_OSX (application));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gedit_app_osx_window_removed (GtkApplication *application,
|
||||||
|
GtkWindow *window)
|
||||||
|
{
|
||||||
|
GTK_APPLICATION_CLASS (gedit_app_osx_parent_class)->window_removed (application, window);
|
||||||
|
|
||||||
|
update_open_sensitivity (GEDIT_APP_OSX (application));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gedit_app_osx_class_init (GeditAppOSXClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
GeditAppClass *app_class = GEDIT_APP_CLASS (klass);
|
||||||
|
GApplicationClass *application_class = G_APPLICATION_CLASS (klass);
|
||||||
|
GtkApplicationClass *gtkapplication_class = GTK_APPLICATION_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->finalize = gedit_app_osx_finalize;
|
||||||
|
object_class->constructed = gedit_app_osx_constructed;
|
||||||
|
|
||||||
|
application_class->startup = gedit_app_osx_startup;
|
||||||
|
|
||||||
|
gtkapplication_class->window_added = gedit_app_osx_window_added;
|
||||||
|
gtkapplication_class->window_removed = gedit_app_osx_window_removed;
|
||||||
|
|
||||||
|
app_class->show_help = gedit_app_osx_show_help_impl;
|
||||||
|
app_class->set_window_title = gedit_app_osx_set_window_title_impl;
|
||||||
|
app_class->create_window = gedit_app_osx_create_window_impl;
|
||||||
|
app_class->process_window_event = gedit_app_osx_process_window_event_impl;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gedit_app_osx_init (GeditAppOSX *app)
|
||||||
|
{
|
||||||
|
/* This is required so that Cocoa is not going to parse the
|
||||||
|
command line arguments by itself and generate OpenFile events.
|
||||||
|
We already parse the command line ourselves, so this is needed
|
||||||
|
to prevent opening files twice, etc. */
|
||||||
|
[[NSUserDefaults standardUserDefaults] setObject:@"NO"
|
||||||
|
forKey:@"NSTreatUnknownArgumentsAsOpen"];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ex:set ts=8 noet: */
|
60
gedit/gedit-app-private.h
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
/*
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 2015 - Sébastien Wilmet <swilmet@gnome.org>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GEDIT_APP_PRIVATE_H
|
||||||
|
#define GEDIT_APP_PRIVATE_H
|
||||||
|
|
||||||
|
#include "gedit-app.h"
|
||||||
|
#include "gedit-menu-extension.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
/* global print config */
|
||||||
|
GtkPageSetup * _gedit_app_get_default_page_setup (GeditApp *app);
|
||||||
|
|
||||||
|
void _gedit_app_set_default_page_setup (GeditApp *app,
|
||||||
|
GtkPageSetup *page_setup);
|
||||||
|
|
||||||
|
GtkPrintSettings * _gedit_app_get_default_print_settings (GeditApp *app);
|
||||||
|
|
||||||
|
void _gedit_app_set_default_print_settings (GeditApp *app,
|
||||||
|
GtkPrintSettings *settings);
|
||||||
|
|
||||||
|
GMenuModel * _gedit_app_get_hamburger_menu (GeditApp *app);
|
||||||
|
|
||||||
|
GMenuModel * _gedit_app_get_notebook_menu (GeditApp *app);
|
||||||
|
|
||||||
|
GMenuModel * _gedit_app_get_tab_width_menu (GeditApp *app);
|
||||||
|
|
||||||
|
GeditMenuExtension * _gedit_app_extend_menu (GeditApp *app,
|
||||||
|
const gchar *extension_point);
|
||||||
|
|
||||||
|
void _gedit_app_set_window_title (GeditApp *app,
|
||||||
|
GeditWindow *window,
|
||||||
|
const gchar *title);
|
||||||
|
|
||||||
|
gboolean _gedit_app_process_window_event (GeditApp *app,
|
||||||
|
GeditWindow *window,
|
||||||
|
GdkEvent *event);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* GEDIT_APP_PRIVATE_H */
|
||||||
|
|
||||||
|
/* ex:set ts=8 noet: */
|
138
gedit/gedit-app-win32.c
Normal file
|
@ -0,0 +1,138 @@
|
||||||
|
/*
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 - Jesse van den Kieboom
|
||||||
|
*
|
||||||
|
* gedit is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* gedit is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with gedit; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||||
|
* Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "gedit-app-win32.h"
|
||||||
|
|
||||||
|
#define SAVE_DATADIR DATADIR
|
||||||
|
#undef DATADIR
|
||||||
|
|
||||||
|
#include <io.h>
|
||||||
|
#include <conio.h>
|
||||||
|
|
||||||
|
#ifndef _WIN32_WINNT
|
||||||
|
# define _WIN32_WINNT 0x0501
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
#define DATADIR SAVE_DATADIR
|
||||||
|
#undef SAVE_DATADIR
|
||||||
|
|
||||||
|
struct _GeditAppWin32
|
||||||
|
{
|
||||||
|
GeditApp parent_instance;
|
||||||
|
};
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (GeditAppWin32, gedit_app_win32, GEDIT_TYPE_APP)
|
||||||
|
|
||||||
|
static gchar *
|
||||||
|
gedit_app_win32_get_help_uri_impl (GeditApp *app,
|
||||||
|
const gchar *name_of_user_manual,
|
||||||
|
const gchar *link_id_within_user_manual)
|
||||||
|
{
|
||||||
|
/* FIXME: name_of_user_manual is expected to be always "gedit" here. */
|
||||||
|
|
||||||
|
if (link_id_within_user_manual != NULL)
|
||||||
|
{
|
||||||
|
return g_strdup_printf ("https://gedit-technology.github.io/user-manuals/gedit/%s",
|
||||||
|
link_id_within_user_manual);
|
||||||
|
}
|
||||||
|
|
||||||
|
return g_strdup ("https://gedit-technology.github.io/user-manuals/gedit/");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
setup_path (void)
|
||||||
|
{
|
||||||
|
gchar *path;
|
||||||
|
gchar *installdir;
|
||||||
|
gchar *bin;
|
||||||
|
|
||||||
|
installdir = g_win32_get_package_installation_directory_of_module (NULL);
|
||||||
|
|
||||||
|
bin = g_build_filename (installdir, "bin", NULL);
|
||||||
|
g_free (installdir);
|
||||||
|
|
||||||
|
/* Set PATH to include the gedit executable's folder */
|
||||||
|
path = g_build_path (";", bin, g_getenv ("PATH"), NULL);
|
||||||
|
g_free (bin);
|
||||||
|
|
||||||
|
if (!g_setenv ("PATH", path, TRUE))
|
||||||
|
{
|
||||||
|
g_warning ("Could not set PATH for gedit");
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (path);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
prep_console (void)
|
||||||
|
{
|
||||||
|
/* If we open gedit from a console get the stdout printing */
|
||||||
|
if (fileno (stdout) != -1 &&
|
||||||
|
_get_osfhandle (fileno (stdout)) != -1)
|
||||||
|
{
|
||||||
|
/* stdout is fine, presumably redirected to a file or pipe */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
typedef BOOL (* WINAPI AttachConsole_t) (DWORD);
|
||||||
|
|
||||||
|
AttachConsole_t p_AttachConsole =
|
||||||
|
(AttachConsole_t) GetProcAddress (GetModuleHandle ("kernel32.dll"),
|
||||||
|
"AttachConsole");
|
||||||
|
|
||||||
|
if (p_AttachConsole != NULL && p_AttachConsole (ATTACH_PARENT_PROCESS))
|
||||||
|
{
|
||||||
|
freopen ("CONOUT$", "w", stdout);
|
||||||
|
dup2 (fileno (stdout), 1);
|
||||||
|
freopen ("CONOUT$", "w", stderr);
|
||||||
|
dup2 (fileno (stderr), 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gedit_app_win32_startup (GApplication *application)
|
||||||
|
{
|
||||||
|
G_APPLICATION_CLASS (gedit_app_win32_parent_class)->startup (application);
|
||||||
|
|
||||||
|
setup_path ();
|
||||||
|
prep_console ();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gedit_app_win32_class_init (GeditAppWin32Class *klass)
|
||||||
|
{
|
||||||
|
GApplicationClass *gapp_class = G_APPLICATION_CLASS (klass);
|
||||||
|
GeditAppClass *app_class = GEDIT_APP_CLASS (klass);
|
||||||
|
|
||||||
|
gapp_class->startup = gedit_app_win32_startup;
|
||||||
|
|
||||||
|
app_class->get_help_uri = gedit_app_win32_get_help_uri_impl;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gedit_app_win32_init (GeditAppWin32 *self)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ex:set ts=8 noet: */
|
39
gedit/gedit-app-win32.h
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 - Jesse van den Kieboom
|
||||||
|
*
|
||||||
|
* gedit is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* gedit is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with gedit; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||||
|
* Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GEDIT_APP_WIN32_H
|
||||||
|
#define GEDIT_APP_WIN32_H
|
||||||
|
|
||||||
|
#include "gedit-app.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define GEDIT_TYPE_APP_WIN32 (gedit_app_win32_get_type ())
|
||||||
|
|
||||||
|
G_DECLARE_FINAL_TYPE (GeditAppWin32, gedit_app_win32,
|
||||||
|
GEDIT, APP_WIN32,
|
||||||
|
GeditApp)
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* GEDIT_APP_WIN32_H */
|
||||||
|
|
||||||
|
/* ex:set ts=8 noet: */
|
1685
gedit/gedit-app.c
Normal file
75
gedit/gedit-app.h
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
/*
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 2005 - Paolo Maggi
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GEDIT_APP_H
|
||||||
|
#define GEDIT_APP_H
|
||||||
|
|
||||||
|
#include <gedit/gedit-window.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define GEDIT_TYPE_APP (gedit_app_get_type())
|
||||||
|
|
||||||
|
G_DECLARE_DERIVABLE_TYPE (GeditApp, gedit_app,
|
||||||
|
GEDIT, APP,
|
||||||
|
GtkApplication)
|
||||||
|
|
||||||
|
struct _GeditAppClass
|
||||||
|
{
|
||||||
|
GtkApplicationClass parent_class;
|
||||||
|
|
||||||
|
gboolean (*show_help) (GeditApp *app,
|
||||||
|
GtkWindow *parent_window,
|
||||||
|
const gchar *name_of_user_manual,
|
||||||
|
const gchar *link_id_within_user_manual);
|
||||||
|
|
||||||
|
gchar *(*get_help_uri) (GeditApp *app,
|
||||||
|
const gchar *name_of_user_manual,
|
||||||
|
const gchar *link_id_within_user_manual);
|
||||||
|
|
||||||
|
void (*set_window_title) (GeditApp *app,
|
||||||
|
GeditWindow *window,
|
||||||
|
const gchar *title);
|
||||||
|
|
||||||
|
GeditWindow *(*create_window) (GeditApp *app);
|
||||||
|
|
||||||
|
gboolean (*process_window_event) (GeditApp *app,
|
||||||
|
GeditWindow *window,
|
||||||
|
GdkEvent *event);
|
||||||
|
};
|
||||||
|
|
||||||
|
GeditWindow * gedit_app_create_window (GeditApp *app,
|
||||||
|
GdkScreen *screen);
|
||||||
|
|
||||||
|
GList * gedit_app_get_main_windows (GeditApp *app);
|
||||||
|
|
||||||
|
GList * gedit_app_get_documents (GeditApp *app);
|
||||||
|
|
||||||
|
GList * gedit_app_get_views (GeditApp *app);
|
||||||
|
|
||||||
|
gboolean gedit_app_show_help (GeditApp *app,
|
||||||
|
GtkWindow *parent_window,
|
||||||
|
const gchar *name_of_user_manual,
|
||||||
|
const gchar *link_id_within_user_manual);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* GEDIT_APP_H */
|
||||||
|
|
||||||
|
/* ex:set ts=8 noet: */
|
178
gedit/gedit-bottom-panel.c
Normal file
|
@ -0,0 +1,178 @@
|
||||||
|
/* SPDX-FileCopyrightText: 2024 - Sébastien Wilmet
|
||||||
|
* SPDX-License-Identifier: LGPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "gedit-bottom-panel.h"
|
||||||
|
#include <glib/gi18n.h>
|
||||||
|
#include "gedit-settings.h"
|
||||||
|
|
||||||
|
struct _GeditBottomPanelPrivate
|
||||||
|
{
|
||||||
|
TeplPanelSimple *panel_simple;
|
||||||
|
TeplPanelNotebook *panel_notebook;
|
||||||
|
|
||||||
|
gint height;
|
||||||
|
};
|
||||||
|
|
||||||
|
G_DEFINE_TYPE_WITH_PRIVATE (GeditBottomPanel, _gedit_bottom_panel, GTK_TYPE_GRID)
|
||||||
|
|
||||||
|
static void
|
||||||
|
_gedit_bottom_panel_dispose (GObject *object)
|
||||||
|
{
|
||||||
|
GeditBottomPanel *panel = GEDIT_BOTTOM_PANEL (object);
|
||||||
|
|
||||||
|
g_clear_object (&panel->priv->panel_simple);
|
||||||
|
g_clear_object (&panel->priv->panel_notebook);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (_gedit_bottom_panel_parent_class)->dispose (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_gedit_bottom_panel_class_init (GeditBottomPanelClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->dispose = _gedit_bottom_panel_dispose;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
init_height (GeditBottomPanel *panel)
|
||||||
|
{
|
||||||
|
GeditSettings *settings;
|
||||||
|
GSettings *window_state_settings;
|
||||||
|
|
||||||
|
settings = _gedit_settings_get_singleton ();
|
||||||
|
window_state_settings = _gedit_settings_peek_window_state_settings (settings);
|
||||||
|
|
||||||
|
panel->priv->height = g_settings_get_int (window_state_settings,
|
||||||
|
GEDIT_SETTINGS_BOTTOM_PANEL_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static GtkNotebook *
|
||||||
|
create_notebook (void)
|
||||||
|
{
|
||||||
|
GtkNotebook *notebook;
|
||||||
|
|
||||||
|
notebook = GTK_NOTEBOOK (gtk_notebook_new ());
|
||||||
|
gtk_notebook_set_tab_pos (notebook, GTK_POS_BOTTOM);
|
||||||
|
gtk_notebook_set_scrollable (notebook, TRUE);
|
||||||
|
gtk_notebook_set_show_border (notebook, FALSE);
|
||||||
|
gtk_container_set_border_width (GTK_CONTAINER (notebook), 0);
|
||||||
|
gtk_widget_set_hexpand (GTK_WIDGET (notebook), TRUE);
|
||||||
|
gtk_widget_set_vexpand (GTK_WIDGET (notebook), TRUE);
|
||||||
|
gtk_widget_show (GTK_WIDGET (notebook));
|
||||||
|
|
||||||
|
return notebook;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GtkWidget *
|
||||||
|
create_close_button (void)
|
||||||
|
{
|
||||||
|
GtkWidget *close_button;
|
||||||
|
|
||||||
|
close_button = tepl_utils_create_close_button ();
|
||||||
|
gtk_widget_set_tooltip_text (close_button, _("Hide panel"));
|
||||||
|
gtk_actionable_set_action_name (GTK_ACTIONABLE (close_button), "win.bottom-panel");
|
||||||
|
gtk_widget_set_valign (close_button, GTK_ALIGN_START);
|
||||||
|
gtk_widget_show (close_button);
|
||||||
|
|
||||||
|
return close_button;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_gedit_bottom_panel_init (GeditBottomPanel *panel)
|
||||||
|
{
|
||||||
|
GtkNotebook *notebook;
|
||||||
|
|
||||||
|
panel->priv = _gedit_bottom_panel_get_instance_private (panel);
|
||||||
|
|
||||||
|
init_height (panel);
|
||||||
|
|
||||||
|
notebook = create_notebook ();
|
||||||
|
gtk_container_add (GTK_CONTAINER (panel),
|
||||||
|
GTK_WIDGET (notebook));
|
||||||
|
gtk_container_add (GTK_CONTAINER (panel),
|
||||||
|
create_close_button ());
|
||||||
|
|
||||||
|
panel->priv->panel_simple = tepl_panel_simple_new ();
|
||||||
|
panel->priv->panel_notebook = tepl_panel_notebook_new (panel->priv->panel_simple,
|
||||||
|
notebook);
|
||||||
|
}
|
||||||
|
|
||||||
|
GeditBottomPanel *
|
||||||
|
_gedit_bottom_panel_new (void)
|
||||||
|
{
|
||||||
|
return g_object_new (GEDIT_TYPE_BOTTOM_PANEL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
TeplPanelSimple *
|
||||||
|
_gedit_bottom_panel_get_panel_simple (GeditBottomPanel *panel)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GEDIT_IS_BOTTOM_PANEL (panel), NULL);
|
||||||
|
return panel->priv->panel_simple;
|
||||||
|
}
|
||||||
|
|
||||||
|
gint
|
||||||
|
_gedit_bottom_panel_get_height (GeditBottomPanel *panel)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GEDIT_IS_BOTTOM_PANEL (panel), 0);
|
||||||
|
return panel->priv->height;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gedit_bottom_panel_set_height (GeditBottomPanel *panel,
|
||||||
|
gint height)
|
||||||
|
{
|
||||||
|
g_return_if_fail (GEDIT_IS_BOTTOM_PANEL (panel));
|
||||||
|
panel->priv->height = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gedit_bottom_panel_save_state (GeditBottomPanel *panel)
|
||||||
|
{
|
||||||
|
GeditSettings *settings;
|
||||||
|
GSettings *window_state_settings;
|
||||||
|
const gchar *active_item_name;
|
||||||
|
|
||||||
|
g_return_if_fail (GEDIT_IS_BOTTOM_PANEL (panel));
|
||||||
|
|
||||||
|
settings = _gedit_settings_get_singleton ();
|
||||||
|
window_state_settings = _gedit_settings_peek_window_state_settings (settings);
|
||||||
|
|
||||||
|
active_item_name = tepl_panel_simple_get_active_item_name (panel->priv->panel_simple);
|
||||||
|
if (active_item_name != NULL)
|
||||||
|
{
|
||||||
|
g_settings_set_string (window_state_settings,
|
||||||
|
GEDIT_SETTINGS_BOTTOM_PANEL_ACTIVE_PAGE,
|
||||||
|
active_item_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (panel->priv->height > 0)
|
||||||
|
{
|
||||||
|
g_settings_set_int (window_state_settings,
|
||||||
|
GEDIT_SETTINGS_BOTTOM_PANEL_SIZE,
|
||||||
|
panel->priv->height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gedit_bottom_panel_copy_settings (GeditBottomPanel *origin,
|
||||||
|
GeditBottomPanel *target)
|
||||||
|
{
|
||||||
|
const gchar *active_item_name;
|
||||||
|
|
||||||
|
g_return_if_fail (GEDIT_IS_BOTTOM_PANEL (origin));
|
||||||
|
g_return_if_fail (GEDIT_IS_BOTTOM_PANEL (target));
|
||||||
|
|
||||||
|
target->priv->height = origin->priv->height;
|
||||||
|
|
||||||
|
active_item_name = tepl_panel_simple_get_active_item_name (origin->priv->panel_simple);
|
||||||
|
if (active_item_name != NULL)
|
||||||
|
{
|
||||||
|
tepl_panel_simple_set_active_item_name (target->priv->panel_simple,
|
||||||
|
active_item_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_widget_set_visible (GTK_WIDGET (target),
|
||||||
|
gtk_widget_get_visible (GTK_WIDGET (origin)));
|
||||||
|
}
|
60
gedit/gedit-bottom-panel.h
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
/* SPDX-FileCopyrightText: 2024 - Sébastien Wilmet
|
||||||
|
* SPDX-License-Identifier: LGPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GEDIT_BOTTOM_PANEL_H
|
||||||
|
#define GEDIT_BOTTOM_PANEL_H
|
||||||
|
|
||||||
|
#include <tepl/tepl.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define GEDIT_TYPE_BOTTOM_PANEL (_gedit_bottom_panel_get_type ())
|
||||||
|
#define GEDIT_BOTTOM_PANEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_BOTTOM_PANEL, GeditBottomPanel))
|
||||||
|
#define GEDIT_BOTTOM_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEDIT_TYPE_BOTTOM_PANEL, GeditBottomPanelClass))
|
||||||
|
#define GEDIT_IS_BOTTOM_PANEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEDIT_TYPE_BOTTOM_PANEL))
|
||||||
|
#define GEDIT_IS_BOTTOM_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_BOTTOM_PANEL))
|
||||||
|
#define GEDIT_BOTTOM_PANEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEDIT_TYPE_BOTTOM_PANEL, GeditBottomPanelClass))
|
||||||
|
|
||||||
|
typedef struct _GeditBottomPanel GeditBottomPanel;
|
||||||
|
typedef struct _GeditBottomPanelClass GeditBottomPanelClass;
|
||||||
|
typedef struct _GeditBottomPanelPrivate GeditBottomPanelPrivate;
|
||||||
|
|
||||||
|
struct _GeditBottomPanel
|
||||||
|
{
|
||||||
|
GtkGrid parent;
|
||||||
|
|
||||||
|
GeditBottomPanelPrivate *priv;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GeditBottomPanelClass
|
||||||
|
{
|
||||||
|
GtkGridClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
G_GNUC_INTERNAL
|
||||||
|
GType _gedit_bottom_panel_get_type (void);
|
||||||
|
|
||||||
|
G_GNUC_INTERNAL
|
||||||
|
GeditBottomPanel * _gedit_bottom_panel_new (void);
|
||||||
|
|
||||||
|
G_GNUC_INTERNAL
|
||||||
|
TeplPanelSimple * _gedit_bottom_panel_get_panel_simple (GeditBottomPanel *panel);
|
||||||
|
|
||||||
|
G_GNUC_INTERNAL
|
||||||
|
gint _gedit_bottom_panel_get_height (GeditBottomPanel *panel);
|
||||||
|
|
||||||
|
G_GNUC_INTERNAL
|
||||||
|
void _gedit_bottom_panel_set_height (GeditBottomPanel *panel,
|
||||||
|
gint height);
|
||||||
|
|
||||||
|
G_GNUC_INTERNAL
|
||||||
|
void _gedit_bottom_panel_save_state (GeditBottomPanel *panel);
|
||||||
|
|
||||||
|
G_GNUC_INTERNAL
|
||||||
|
void _gedit_bottom_panel_copy_settings (GeditBottomPanel *origin,
|
||||||
|
GeditBottomPanel *target);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* GEDIT_BOTTOM_PANEL_H */
|
548
gedit/gedit-close-confirmation-dialog.c
Normal file
|
@ -0,0 +1,548 @@
|
||||||
|
/*
|
||||||
|
* gedit-close-confirmation-dialog.c
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 2004-2005 GNOME Foundation
|
||||||
|
* Copyright (C) 2015 Sébastien Wilmet
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "gedit-close-confirmation-dialog.h"
|
||||||
|
|
||||||
|
#include <glib/gi18n.h>
|
||||||
|
|
||||||
|
#include <gedit/gedit-app.h>
|
||||||
|
#include <gedit/gedit-document.h>
|
||||||
|
#include <gedit/gedit-document-private.h>
|
||||||
|
#include <gedit/gedit-utils.h>
|
||||||
|
#include <gedit/gedit-window.h>
|
||||||
|
|
||||||
|
/* Mode */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
SINGLE_DOC_MODE,
|
||||||
|
MULTIPLE_DOCS_MODE
|
||||||
|
};
|
||||||
|
|
||||||
|
#define GET_MODE(dlg) (((dlg->unsaved_documents != NULL) && \
|
||||||
|
(dlg->unsaved_documents->next == NULL)) ? \
|
||||||
|
SINGLE_DOC_MODE : MULTIPLE_DOCS_MODE)
|
||||||
|
|
||||||
|
#define GEDIT_SAVE_DOCUMENT_KEY "gedit-save-document"
|
||||||
|
|
||||||
|
struct _GeditCloseConfirmationDialog
|
||||||
|
{
|
||||||
|
GtkMessageDialog parent_instance;
|
||||||
|
|
||||||
|
GList *unsaved_documents;
|
||||||
|
GList *selected_documents;
|
||||||
|
GtkWidget *list_box;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
PROP_0,
|
||||||
|
PROP_UNSAVED_DOCUMENTS,
|
||||||
|
LAST_PROP
|
||||||
|
};
|
||||||
|
|
||||||
|
static GParamSpec *properties[LAST_PROP];
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (GeditCloseConfirmationDialog,
|
||||||
|
gedit_close_confirmation_dialog,
|
||||||
|
GTK_TYPE_MESSAGE_DIALOG)
|
||||||
|
|
||||||
|
static void set_unsaved_document (GeditCloseConfirmationDialog *dlg,
|
||||||
|
const GList *list);
|
||||||
|
|
||||||
|
static GList *
|
||||||
|
get_selected_docs (GtkWidget *list_box)
|
||||||
|
{
|
||||||
|
GList *rows;
|
||||||
|
GList *l;
|
||||||
|
GList *ret = NULL;
|
||||||
|
|
||||||
|
rows = gtk_container_get_children (GTK_CONTAINER (list_box));
|
||||||
|
for (l = rows; l != NULL; l = l->next)
|
||||||
|
{
|
||||||
|
GtkWidget *row = l->data;
|
||||||
|
GtkWidget *check_button;
|
||||||
|
|
||||||
|
check_button = gtk_bin_get_child (GTK_BIN (row));
|
||||||
|
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check_button)))
|
||||||
|
{
|
||||||
|
GeditDocument *doc;
|
||||||
|
|
||||||
|
doc = g_object_get_data (G_OBJECT (row), GEDIT_SAVE_DOCUMENT_KEY);
|
||||||
|
g_return_val_if_fail (doc != NULL, NULL);
|
||||||
|
|
||||||
|
ret = g_list_prepend (ret, doc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
g_list_free (rows);
|
||||||
|
|
||||||
|
return g_list_reverse (ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Since we connect in the constructor we are sure this handler will be called
|
||||||
|
* before the user ones.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
response_cb (GeditCloseConfirmationDialog *dlg,
|
||||||
|
gint response_id,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
g_return_if_fail (GEDIT_IS_CLOSE_CONFIRMATION_DIALOG (dlg));
|
||||||
|
|
||||||
|
if (dlg->selected_documents != NULL)
|
||||||
|
{
|
||||||
|
g_list_free (dlg->selected_documents);
|
||||||
|
dlg->selected_documents = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (response_id == GTK_RESPONSE_YES)
|
||||||
|
{
|
||||||
|
if (GET_MODE (dlg) == SINGLE_DOC_MODE)
|
||||||
|
{
|
||||||
|
dlg->selected_documents = g_list_copy (dlg->unsaved_documents);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dlg->selected_documents = get_selected_docs (dlg->list_box);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gedit_close_confirmation_dialog_init (GeditCloseConfirmationDialog *dlg)
|
||||||
|
{
|
||||||
|
gtk_window_set_title (GTK_WINDOW (dlg), "");
|
||||||
|
gtk_window_set_modal (GTK_WINDOW (dlg), TRUE);
|
||||||
|
gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
|
||||||
|
|
||||||
|
g_signal_connect (dlg,
|
||||||
|
"response",
|
||||||
|
G_CALLBACK (response_cb),
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gedit_close_confirmation_dialog_finalize (GObject *object)
|
||||||
|
{
|
||||||
|
GeditCloseConfirmationDialog *dlg = GEDIT_CLOSE_CONFIRMATION_DIALOG (object);
|
||||||
|
|
||||||
|
g_list_free (dlg->unsaved_documents);
|
||||||
|
g_list_free (dlg->selected_documents);
|
||||||
|
|
||||||
|
/* Call the parent's destructor */
|
||||||
|
G_OBJECT_CLASS (gedit_close_confirmation_dialog_parent_class)->finalize (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gedit_close_confirmation_dialog_set_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
const GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
GeditCloseConfirmationDialog *dlg;
|
||||||
|
|
||||||
|
dlg = GEDIT_CLOSE_CONFIRMATION_DIALOG (object);
|
||||||
|
|
||||||
|
switch (prop_id)
|
||||||
|
{
|
||||||
|
case PROP_UNSAVED_DOCUMENTS:
|
||||||
|
set_unsaved_document (dlg, g_value_get_pointer (value));
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gedit_close_confirmation_dialog_get_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
GeditCloseConfirmationDialog *dlg = GEDIT_CLOSE_CONFIRMATION_DIALOG (object);
|
||||||
|
|
||||||
|
switch (prop_id)
|
||||||
|
{
|
||||||
|
case PROP_UNSAVED_DOCUMENTS:
|
||||||
|
g_value_set_pointer (value, dlg->unsaved_documents);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gedit_close_confirmation_dialog_class_init (GeditCloseConfirmationDialogClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
gobject_class->set_property = gedit_close_confirmation_dialog_set_property;
|
||||||
|
gobject_class->get_property = gedit_close_confirmation_dialog_get_property;
|
||||||
|
gobject_class->finalize = gedit_close_confirmation_dialog_finalize;
|
||||||
|
|
||||||
|
properties[PROP_UNSAVED_DOCUMENTS] =
|
||||||
|
g_param_spec_pointer ("unsaved-documents",
|
||||||
|
"Unsaved Documents",
|
||||||
|
"List of Unsaved Documents",
|
||||||
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
|
||||||
|
|
||||||
|
g_object_class_install_properties (gobject_class, LAST_PROP, properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
GList *
|
||||||
|
gedit_close_confirmation_dialog_get_selected_documents (GeditCloseConfirmationDialog *dlg)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GEDIT_IS_CLOSE_CONFIRMATION_DIALOG (dlg), NULL);
|
||||||
|
|
||||||
|
return g_list_copy (dlg->selected_documents);
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkWidget *
|
||||||
|
gedit_close_confirmation_dialog_new (GtkWindow *parent,
|
||||||
|
GList *unsaved_documents)
|
||||||
|
{
|
||||||
|
GtkWidget *dlg;
|
||||||
|
|
||||||
|
g_return_val_if_fail (unsaved_documents != NULL, NULL);
|
||||||
|
|
||||||
|
dlg = g_object_new (GEDIT_TYPE_CLOSE_CONFIRMATION_DIALOG,
|
||||||
|
"unsaved-documents", unsaved_documents,
|
||||||
|
"message-type", GTK_MESSAGE_QUESTION,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if (parent != NULL)
|
||||||
|
{
|
||||||
|
gtk_window_group_add_window (gedit_window_get_group (GEDIT_WINDOW (parent)),
|
||||||
|
GTK_WINDOW (dlg));
|
||||||
|
|
||||||
|
gtk_window_set_transient_for (GTK_WINDOW (dlg), parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
return dlg;
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkWidget *
|
||||||
|
gedit_close_confirmation_dialog_new_single (GtkWindow *parent,
|
||||||
|
GeditDocument *doc)
|
||||||
|
{
|
||||||
|
GtkWidget *dlg;
|
||||||
|
GList *unsaved_documents;
|
||||||
|
|
||||||
|
g_return_val_if_fail (doc != NULL, NULL);
|
||||||
|
|
||||||
|
unsaved_documents = g_list_prepend (NULL, doc);
|
||||||
|
dlg = gedit_close_confirmation_dialog_new (parent, unsaved_documents);
|
||||||
|
g_list_free (unsaved_documents);
|
||||||
|
|
||||||
|
return dlg;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
add_buttons (GeditCloseConfirmationDialog *dlg)
|
||||||
|
{
|
||||||
|
GtkWidget *close_button;
|
||||||
|
gboolean save_as = FALSE;
|
||||||
|
|
||||||
|
close_button = gtk_dialog_add_button (GTK_DIALOG (dlg),
|
||||||
|
_("Close _without Saving"),
|
||||||
|
GTK_RESPONSE_NO);
|
||||||
|
|
||||||
|
gtk_style_context_add_class (gtk_widget_get_style_context (close_button),
|
||||||
|
"destructive-action");
|
||||||
|
|
||||||
|
gtk_dialog_add_button (GTK_DIALOG (dlg), _("_Cancel"), GTK_RESPONSE_CANCEL);
|
||||||
|
|
||||||
|
if (GET_MODE (dlg) == SINGLE_DOC_MODE)
|
||||||
|
{
|
||||||
|
GeditDocument *doc;
|
||||||
|
GtkSourceFile *file;
|
||||||
|
|
||||||
|
doc = GEDIT_DOCUMENT (dlg->unsaved_documents->data);
|
||||||
|
file = gedit_document_get_file (doc);
|
||||||
|
|
||||||
|
if (gtk_source_file_is_readonly (file) ||
|
||||||
|
_gedit_document_is_untitled (doc))
|
||||||
|
{
|
||||||
|
save_as = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_dialog_add_button (GTK_DIALOG (dlg),
|
||||||
|
save_as ? _("_Save As…") : _("_Save"),
|
||||||
|
GTK_RESPONSE_YES);
|
||||||
|
gtk_dialog_set_default_response (GTK_DIALOG (dlg),
|
||||||
|
GTK_RESPONSE_YES);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gchar *
|
||||||
|
get_text_secondary_label (GeditDocument *doc)
|
||||||
|
{
|
||||||
|
glong seconds;
|
||||||
|
gchar *secondary_msg;
|
||||||
|
|
||||||
|
seconds = MAX (1, _gedit_document_get_seconds_since_last_save_or_load (doc));
|
||||||
|
|
||||||
|
if (seconds < 55)
|
||||||
|
{
|
||||||
|
secondary_msg = g_strdup_printf (
|
||||||
|
ngettext ("If you don’t save, changes from the last %ld second "
|
||||||
|
"will be permanently lost.",
|
||||||
|
"If you don’t save, changes from the last %ld seconds "
|
||||||
|
"will be permanently lost.",
|
||||||
|
seconds),
|
||||||
|
seconds);
|
||||||
|
}
|
||||||
|
else if (seconds < 75) /* 55 <= seconds < 75 */
|
||||||
|
{
|
||||||
|
secondary_msg = g_strdup (_("If you don’t save, changes from the last minute "
|
||||||
|
"will be permanently lost."));
|
||||||
|
}
|
||||||
|
else if (seconds < 110) /* 75 <= seconds < 110 */
|
||||||
|
{
|
||||||
|
secondary_msg = g_strdup_printf (
|
||||||
|
ngettext ("If you don’t save, changes from the last minute and %ld "
|
||||||
|
"second will be permanently lost.",
|
||||||
|
"If you don’t save, changes from the last minute and %ld "
|
||||||
|
"seconds will be permanently lost.",
|
||||||
|
seconds - 60 ),
|
||||||
|
seconds - 60);
|
||||||
|
}
|
||||||
|
else if (seconds < 3600)
|
||||||
|
{
|
||||||
|
secondary_msg = g_strdup_printf (
|
||||||
|
ngettext ("If you don’t save, changes from the last %ld minute "
|
||||||
|
"will be permanently lost.",
|
||||||
|
"If you don’t save, changes from the last %ld minutes "
|
||||||
|
"will be permanently lost.",
|
||||||
|
seconds / 60),
|
||||||
|
seconds / 60);
|
||||||
|
}
|
||||||
|
else if (seconds < 7200)
|
||||||
|
{
|
||||||
|
gint minutes;
|
||||||
|
seconds -= 3600;
|
||||||
|
|
||||||
|
minutes = seconds / 60;
|
||||||
|
if (minutes < 5)
|
||||||
|
{
|
||||||
|
secondary_msg = g_strdup (_("If you don’t save, changes from the last hour "
|
||||||
|
"will be permanently lost."));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
secondary_msg = g_strdup_printf (
|
||||||
|
ngettext ("If you don’t save, changes from the last hour and %d "
|
||||||
|
"minute will be permanently lost.",
|
||||||
|
"If you don’t save, changes from the last hour and %d "
|
||||||
|
"minutes will be permanently lost.",
|
||||||
|
minutes),
|
||||||
|
minutes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gint hours;
|
||||||
|
|
||||||
|
hours = seconds / 3600;
|
||||||
|
|
||||||
|
secondary_msg = g_strdup_printf (
|
||||||
|
ngettext ("If you don’t save, changes from the last %d hour "
|
||||||
|
"will be permanently lost.",
|
||||||
|
"If you don’t save, changes from the last %d hours "
|
||||||
|
"will be permanently lost.",
|
||||||
|
hours),
|
||||||
|
hours);
|
||||||
|
}
|
||||||
|
|
||||||
|
return secondary_msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
build_single_doc_dialog (GeditCloseConfirmationDialog *dlg)
|
||||||
|
{
|
||||||
|
GeditDocument *doc;
|
||||||
|
gchar *doc_name;
|
||||||
|
gchar *str;
|
||||||
|
gchar *markup_str;
|
||||||
|
|
||||||
|
g_return_if_fail (dlg->unsaved_documents->data != NULL);
|
||||||
|
doc = GEDIT_DOCUMENT (dlg->unsaved_documents->data);
|
||||||
|
|
||||||
|
add_buttons (dlg);
|
||||||
|
|
||||||
|
/* Primary message */
|
||||||
|
doc_name = tepl_file_get_short_name (tepl_buffer_get_file (TEPL_BUFFER (doc)));
|
||||||
|
str = g_markup_printf_escaped (_("Save changes to document “%s” before closing?"), doc_name);
|
||||||
|
g_free (doc_name);
|
||||||
|
|
||||||
|
markup_str = g_strconcat ("<span weight=\"bold\" size=\"larger\">", str, "</span>", NULL);
|
||||||
|
g_free (str);
|
||||||
|
|
||||||
|
gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dlg), markup_str);
|
||||||
|
g_free (markup_str);
|
||||||
|
|
||||||
|
/* Secondary message */
|
||||||
|
str = get_text_secondary_label (doc);
|
||||||
|
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dlg), "%s", str);
|
||||||
|
g_free (str);
|
||||||
|
}
|
||||||
|
|
||||||
|
static GtkWidget *
|
||||||
|
create_list_box (GeditCloseConfirmationDialog *dlg)
|
||||||
|
{
|
||||||
|
GtkWidget *list_box;
|
||||||
|
GList *l;
|
||||||
|
|
||||||
|
list_box = gtk_list_box_new ();
|
||||||
|
|
||||||
|
for (l = dlg->unsaved_documents; l != NULL; l = l->next)
|
||||||
|
{
|
||||||
|
GeditDocument *doc = l->data;
|
||||||
|
gchar *name;
|
||||||
|
GtkWidget *check_button;
|
||||||
|
GtkWidget *row;
|
||||||
|
|
||||||
|
name = tepl_file_get_short_name (tepl_buffer_get_file (TEPL_BUFFER (doc)));
|
||||||
|
check_button = gtk_check_button_new_with_label (name);
|
||||||
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button), TRUE);
|
||||||
|
gtk_widget_set_halign (check_button, GTK_ALIGN_START);
|
||||||
|
g_free (name);
|
||||||
|
|
||||||
|
row = gtk_list_box_row_new ();
|
||||||
|
gtk_container_add (GTK_CONTAINER (row), check_button);
|
||||||
|
gtk_widget_show_all (row);
|
||||||
|
|
||||||
|
g_object_set_data_full (G_OBJECT (row),
|
||||||
|
GEDIT_SAVE_DOCUMENT_KEY,
|
||||||
|
g_object_ref (doc),
|
||||||
|
(GDestroyNotify) g_object_unref);
|
||||||
|
|
||||||
|
gtk_list_box_insert (GTK_LIST_BOX (list_box), row, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return list_box;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
build_multiple_docs_dialog (GeditCloseConfirmationDialog *dlg)
|
||||||
|
{
|
||||||
|
GtkWidget *content_area;
|
||||||
|
GtkWidget *vbox;
|
||||||
|
GtkWidget *select_label;
|
||||||
|
GtkWidget *scrolledwindow;
|
||||||
|
GtkWidget *secondary_label;
|
||||||
|
gchar *str;
|
||||||
|
gchar *markup_str;
|
||||||
|
|
||||||
|
add_buttons (dlg);
|
||||||
|
|
||||||
|
gtk_window_set_resizable (GTK_WINDOW (dlg), TRUE);
|
||||||
|
|
||||||
|
/* Primary message */
|
||||||
|
str = g_strdup_printf (
|
||||||
|
ngettext ("There is %d document with unsaved changes. "
|
||||||
|
"Save changes before closing?",
|
||||||
|
"There are %d documents with unsaved changes. "
|
||||||
|
"Save changes before closing?",
|
||||||
|
g_list_length (dlg->unsaved_documents)),
|
||||||
|
g_list_length (dlg->unsaved_documents));
|
||||||
|
|
||||||
|
markup_str = g_strconcat ("<span weight=\"bold\" size=\"larger\">", str, "</span>", NULL);
|
||||||
|
g_free (str);
|
||||||
|
|
||||||
|
gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dlg), markup_str);
|
||||||
|
g_free (markup_str);
|
||||||
|
|
||||||
|
/* List of unsaved documents */
|
||||||
|
content_area = gtk_dialog_get_content_area (GTK_DIALOG (dlg));
|
||||||
|
gtk_box_set_spacing (GTK_BOX (content_area), 10);
|
||||||
|
|
||||||
|
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
|
||||||
|
gtk_widget_set_margin_start (vbox, 30);
|
||||||
|
gtk_widget_set_margin_end (vbox, 30);
|
||||||
|
gtk_widget_set_margin_bottom (vbox, 12);
|
||||||
|
gtk_box_pack_start (GTK_BOX (content_area), vbox, TRUE, TRUE, 0);
|
||||||
|
|
||||||
|
select_label = gtk_label_new_with_mnemonic (_("S_elect the documents you want to save:"));
|
||||||
|
gtk_box_pack_start (GTK_BOX (vbox), select_label, FALSE, FALSE, 0);
|
||||||
|
gtk_label_set_line_wrap (GTK_LABEL (select_label), TRUE);
|
||||||
|
gtk_label_set_max_width_chars (GTK_LABEL (select_label), 72);
|
||||||
|
gtk_widget_set_halign (select_label, GTK_ALIGN_START);
|
||||||
|
|
||||||
|
scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
|
||||||
|
gtk_box_pack_start (GTK_BOX (vbox), scrolledwindow, TRUE, TRUE, 0);
|
||||||
|
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow),
|
||||||
|
GTK_SHADOW_IN);
|
||||||
|
gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (scrolledwindow), 90);
|
||||||
|
|
||||||
|
dlg->list_box = create_list_box (dlg);
|
||||||
|
gtk_container_add (GTK_CONTAINER (scrolledwindow), dlg->list_box);
|
||||||
|
|
||||||
|
/* Secondary label */
|
||||||
|
secondary_label = gtk_label_new (_("If you don’t save, "
|
||||||
|
"all your changes will be permanently lost."));
|
||||||
|
gtk_box_pack_start (GTK_BOX (vbox), secondary_label, FALSE, FALSE, 0);
|
||||||
|
gtk_label_set_line_wrap (GTK_LABEL (secondary_label), TRUE);
|
||||||
|
gtk_widget_set_halign (secondary_label, GTK_ALIGN_CENTER);
|
||||||
|
gtk_widget_set_valign (secondary_label, GTK_ALIGN_START);
|
||||||
|
gtk_label_set_selectable (GTK_LABEL (secondary_label), TRUE);
|
||||||
|
gtk_label_set_max_width_chars (GTK_LABEL (secondary_label), 72);
|
||||||
|
|
||||||
|
gtk_label_set_mnemonic_widget (GTK_LABEL (select_label), dlg->list_box);
|
||||||
|
|
||||||
|
gtk_widget_show_all (vbox);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
set_unsaved_document (GeditCloseConfirmationDialog *dlg,
|
||||||
|
const GList *list)
|
||||||
|
{
|
||||||
|
g_return_if_fail (list != NULL);
|
||||||
|
|
||||||
|
g_return_if_fail (dlg->unsaved_documents == NULL);
|
||||||
|
|
||||||
|
dlg->unsaved_documents = g_list_copy ((GList *)list);
|
||||||
|
|
||||||
|
if (GET_MODE (dlg) == SINGLE_DOC_MODE)
|
||||||
|
{
|
||||||
|
build_single_doc_dialog (dlg);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
build_multiple_docs_dialog (dlg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const GList *
|
||||||
|
gedit_close_confirmation_dialog_get_unsaved_documents (GeditCloseConfirmationDialog *dlg)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GEDIT_IS_CLOSE_CONFIRMATION_DIALOG (dlg), NULL);
|
||||||
|
|
||||||
|
return dlg->unsaved_documents;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ex:set ts=8 noet: */
|
46
gedit/gedit-close-confirmation-dialog.h
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
* gedit-close-confirmation-dialog.h
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 2004-2005 GNOME Foundation
|
||||||
|
* Copyright (C) 2015 Sébastien Wilmet
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GEDIT_CLOSE_CONFIRMATION_DIALOG_H
|
||||||
|
#define GEDIT_CLOSE_CONFIRMATION_DIALOG_H
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
#include <gedit/gedit-document.h>
|
||||||
|
|
||||||
|
#define GEDIT_TYPE_CLOSE_CONFIRMATION_DIALOG (gedit_close_confirmation_dialog_get_type ())
|
||||||
|
|
||||||
|
G_DECLARE_FINAL_TYPE (GeditCloseConfirmationDialog, gedit_close_confirmation_dialog,
|
||||||
|
GEDIT, CLOSE_CONFIRMATION_DIALOG,
|
||||||
|
GtkMessageDialog)
|
||||||
|
|
||||||
|
GtkWidget *gedit_close_confirmation_dialog_new (GtkWindow *parent,
|
||||||
|
GList *unsaved_documents);
|
||||||
|
|
||||||
|
GtkWidget *gedit_close_confirmation_dialog_new_single (GtkWindow *parent,
|
||||||
|
GeditDocument *doc);
|
||||||
|
|
||||||
|
const GList *gedit_close_confirmation_dialog_get_unsaved_documents (GeditCloseConfirmationDialog *dlg);
|
||||||
|
|
||||||
|
GList *gedit_close_confirmation_dialog_get_selected_documents (GeditCloseConfirmationDialog *dlg);
|
||||||
|
|
||||||
|
#endif /* GEDIT_CLOSE_CONFIRMATION_DIALOG_H */
|
||||||
|
/* ex:set ts=8 noet: */
|
91
gedit/gedit-commands-documents.c
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
/*
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
|
||||||
|
* Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi
|
||||||
|
* Copyright (C) 2002-2005 Paolo Maggi
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "gedit-commands-private.h"
|
||||||
|
#include "gedit-window-private.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
_gedit_cmd_documents_previous_document (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GeditWindow *window = GEDIT_WINDOW (user_data);
|
||||||
|
GtkNotebook *notebook;
|
||||||
|
|
||||||
|
notebook = GTK_NOTEBOOK (_gedit_window_get_notebook (window));
|
||||||
|
gtk_notebook_prev_page (notebook);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gedit_cmd_documents_next_document (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GeditWindow *window = GEDIT_WINDOW (user_data);
|
||||||
|
GtkNotebook *notebook;
|
||||||
|
|
||||||
|
notebook = GTK_NOTEBOOK (_gedit_window_get_notebook (window));
|
||||||
|
gtk_notebook_next_page (notebook);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gedit_cmd_documents_move_to_new_window (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GeditWindow *window = GEDIT_WINDOW (user_data);
|
||||||
|
GeditTab *tab;
|
||||||
|
|
||||||
|
tab = gedit_window_get_active_tab (window);
|
||||||
|
|
||||||
|
if (tab != NULL)
|
||||||
|
{
|
||||||
|
_gedit_window_move_tab_to_new_window (window, tab);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Methods related with the tab groups */
|
||||||
|
|
||||||
|
void
|
||||||
|
_gedit_cmd_documents_new_tab_group (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
gedit_multi_notebook_add_new_notebook (_gedit_window_get_multi_notebook (GEDIT_WINDOW (user_data)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gedit_cmd_documents_previous_tab_group (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
gedit_multi_notebook_previous_notebook (_gedit_window_get_multi_notebook (GEDIT_WINDOW (user_data)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gedit_cmd_documents_next_tab_group (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
gedit_multi_notebook_next_notebook (_gedit_window_get_multi_notebook (GEDIT_WINDOW (user_data)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ex:set ts=8 noet: */
|
189
gedit/gedit-commands-edit.c
Normal file
|
@ -0,0 +1,189 @@
|
||||||
|
/*
|
||||||
|
* gedit-commands-edit.c
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
|
||||||
|
* Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi
|
||||||
|
* Copyright (C) 2002-2005 Paolo Maggi
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "gedit-commands.h"
|
||||||
|
#include "gedit-commands-private.h"
|
||||||
|
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
#include "gedit-window.h"
|
||||||
|
#include "gedit-debug.h"
|
||||||
|
#include "gedit-view.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
_gedit_cmd_edit_undo (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GeditWindow *window = GEDIT_WINDOW (user_data);
|
||||||
|
GeditView *active_view;
|
||||||
|
GtkSourceBuffer *active_document;
|
||||||
|
|
||||||
|
gedit_debug (DEBUG_COMMANDS);
|
||||||
|
|
||||||
|
active_view = gedit_window_get_active_view (window);
|
||||||
|
g_return_if_fail (active_view != NULL);
|
||||||
|
|
||||||
|
active_document = GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (active_view)));
|
||||||
|
|
||||||
|
gtk_source_buffer_undo (active_document);
|
||||||
|
|
||||||
|
tepl_view_scroll_to_cursor (TEPL_VIEW (active_view));
|
||||||
|
|
||||||
|
gtk_widget_grab_focus (GTK_WIDGET (active_view));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gedit_cmd_edit_redo (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GeditWindow *window = GEDIT_WINDOW (user_data);
|
||||||
|
GeditView *active_view;
|
||||||
|
GtkSourceBuffer *active_document;
|
||||||
|
|
||||||
|
gedit_debug (DEBUG_COMMANDS);
|
||||||
|
|
||||||
|
active_view = gedit_window_get_active_view (window);
|
||||||
|
g_return_if_fail (active_view != NULL);
|
||||||
|
|
||||||
|
active_document = GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (active_view)));
|
||||||
|
|
||||||
|
gtk_source_buffer_redo (active_document);
|
||||||
|
|
||||||
|
tepl_view_scroll_to_cursor (TEPL_VIEW (active_view));
|
||||||
|
|
||||||
|
gtk_widget_grab_focus (GTK_WIDGET (active_view));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gedit_cmd_edit_cut (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GeditWindow *window = GEDIT_WINDOW (user_data);
|
||||||
|
GeditView *active_view;
|
||||||
|
|
||||||
|
gedit_debug (DEBUG_COMMANDS);
|
||||||
|
|
||||||
|
active_view = gedit_window_get_active_view (window);
|
||||||
|
g_return_if_fail (active_view != NULL);
|
||||||
|
|
||||||
|
tepl_view_cut_clipboard (TEPL_VIEW (active_view));
|
||||||
|
|
||||||
|
gtk_widget_grab_focus (GTK_WIDGET (active_view));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gedit_cmd_edit_copy (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GeditWindow *window = GEDIT_WINDOW (user_data);
|
||||||
|
GeditView *active_view;
|
||||||
|
|
||||||
|
gedit_debug (DEBUG_COMMANDS);
|
||||||
|
|
||||||
|
active_view = gedit_window_get_active_view (window);
|
||||||
|
g_return_if_fail (active_view != NULL);
|
||||||
|
|
||||||
|
tepl_view_copy_clipboard (TEPL_VIEW (active_view));
|
||||||
|
|
||||||
|
gtk_widget_grab_focus (GTK_WIDGET (active_view));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gedit_cmd_edit_paste (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GeditWindow *window = GEDIT_WINDOW (user_data);
|
||||||
|
GeditView *active_view;
|
||||||
|
|
||||||
|
gedit_debug (DEBUG_COMMANDS);
|
||||||
|
|
||||||
|
active_view = gedit_window_get_active_view (window);
|
||||||
|
g_return_if_fail (active_view != NULL);
|
||||||
|
|
||||||
|
tepl_view_paste_clipboard (TEPL_VIEW (active_view));
|
||||||
|
|
||||||
|
gtk_widget_grab_focus (GTK_WIDGET (active_view));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gedit_cmd_edit_delete (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GeditWindow *window = GEDIT_WINDOW (user_data);
|
||||||
|
GeditView *active_view;
|
||||||
|
|
||||||
|
gedit_debug (DEBUG_COMMANDS);
|
||||||
|
|
||||||
|
active_view = gedit_window_get_active_view (window);
|
||||||
|
g_return_if_fail (active_view != NULL);
|
||||||
|
|
||||||
|
tepl_view_delete_selection (TEPL_VIEW (active_view));
|
||||||
|
|
||||||
|
gtk_widget_grab_focus (GTK_WIDGET (active_view));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gedit_cmd_edit_select_all (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GeditWindow *window = GEDIT_WINDOW (user_data);
|
||||||
|
GeditView *active_view;
|
||||||
|
|
||||||
|
gedit_debug (DEBUG_COMMANDS);
|
||||||
|
|
||||||
|
active_view = gedit_window_get_active_view (window);
|
||||||
|
g_return_if_fail (active_view != NULL);
|
||||||
|
|
||||||
|
tepl_view_select_all (TEPL_VIEW (active_view));
|
||||||
|
|
||||||
|
gtk_widget_grab_focus (GTK_WIDGET (active_view));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gedit_cmd_edit_overwrite_mode (GSimpleAction *action,
|
||||||
|
GVariant *state,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GeditWindow *window = GEDIT_WINDOW (user_data);
|
||||||
|
GeditView *active_view;
|
||||||
|
gboolean overwrite;
|
||||||
|
|
||||||
|
gedit_debug (DEBUG_COMMANDS);
|
||||||
|
|
||||||
|
active_view = gedit_window_get_active_view (window);
|
||||||
|
g_return_if_fail (active_view);
|
||||||
|
|
||||||
|
overwrite = g_variant_get_boolean (state);
|
||||||
|
g_simple_action_set_state (action, state);
|
||||||
|
|
||||||
|
gtk_text_view_set_overwrite (GTK_TEXT_VIEW (active_view), overwrite);
|
||||||
|
gtk_widget_grab_focus (GTK_WIDGET (active_view));
|
||||||
|
}
|
41
gedit/gedit-commands-file-print.c
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
|
||||||
|
* Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi
|
||||||
|
* Copyright (C) 2002-2005 Paolo Maggi
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "gedit-commands-private.h"
|
||||||
|
#include "gedit-tab-private.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
_gedit_cmd_file_print (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GeditWindow *window = GEDIT_WINDOW (user_data);
|
||||||
|
GeditTab *tab;
|
||||||
|
|
||||||
|
tab = gedit_window_get_active_tab (window);
|
||||||
|
|
||||||
|
if (tab != NULL)
|
||||||
|
{
|
||||||
|
_gedit_tab_print (tab);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ex:set ts=8 noet: */
|
2139
gedit/gedit-commands-file.c
Normal file
87
gedit/gedit-commands-help.c
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
/*
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
|
||||||
|
* Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi
|
||||||
|
* Copyright (C) 2002-2005 Paolo Maggi
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "gedit-commands-private.h"
|
||||||
|
#include <glib/gi18n.h>
|
||||||
|
#include "gedit-app.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
_gedit_cmd_help_contents (GeditWindow *window)
|
||||||
|
{
|
||||||
|
gedit_app_show_help (GEDIT_APP (g_application_get_default ()),
|
||||||
|
GTK_WINDOW (window),
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gedit_cmd_help_about (GeditWindow *window)
|
||||||
|
{
|
||||||
|
const gchar * const authors[] = {
|
||||||
|
/* Main authors: the top 5 (to not have a too long list), by
|
||||||
|
* relative contribution (number of commits at the time of
|
||||||
|
* writing).
|
||||||
|
*/
|
||||||
|
_("Main authors:"),
|
||||||
|
" Sébastien Wilmet",
|
||||||
|
" Paolo Borelli",
|
||||||
|
" Ignacio Casal Quinteiro",
|
||||||
|
" Jesse van den Kieboom",
|
||||||
|
" Paolo Maggi",
|
||||||
|
"",
|
||||||
|
_("Many thanks also to:"),
|
||||||
|
" Alex Roberts",
|
||||||
|
" Chema Celorio",
|
||||||
|
" Evan Lawrence",
|
||||||
|
" Federico Mena Quintero",
|
||||||
|
" Garrett Regier",
|
||||||
|
" James Willcox",
|
||||||
|
" Sébastien Lafargue",
|
||||||
|
" Steve Frécinaux",
|
||||||
|
"",
|
||||||
|
_("and many other contributors."),
|
||||||
|
"",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
static const gchar * const documenters[] = {
|
||||||
|
"Daniel Neel",
|
||||||
|
"Eric Baudais",
|
||||||
|
"Jim Campbell",
|
||||||
|
"Sun GNOME Documentation Team",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
gtk_show_about_dialog (GTK_WINDOW (window),
|
||||||
|
"authors", authors,
|
||||||
|
"comments", _("gedit is an easy-to-use and general-purpose text editor"),
|
||||||
|
"copyright", "Copyright 1998-2024 – the gedit team",
|
||||||
|
"license-type", GTK_LICENSE_GPL_2_0,
|
||||||
|
"logo-icon-name", "gedit-logo",
|
||||||
|
"documenters", documenters,
|
||||||
|
"translator-credits", _("translator-credits"),
|
||||||
|
"version", VERSION,
|
||||||
|
"website", "https://gedit-technology.github.io/apps/gedit/",
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ex:set ts=8 noet: */
|
169
gedit/gedit-commands-private.h
Normal file
|
@ -0,0 +1,169 @@
|
||||||
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
|
||||||
|
/*
|
||||||
|
* gedit-commands.h
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
|
||||||
|
* Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi
|
||||||
|
* Copyright (C) 2002-2005 Paolo Maggi
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GEDIT_COMMANDS_PRIVATE_H
|
||||||
|
#define GEDIT_COMMANDS_PRIVATE_H
|
||||||
|
|
||||||
|
#include <gtksourceview/gtksource.h>
|
||||||
|
#include <gedit/gedit-window.h>
|
||||||
|
#include <gedit/gedit-notebook.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
/* Create titled documens for non-existing URIs */
|
||||||
|
GSList *_gedit_cmd_load_files_from_prompt (GeditWindow *window,
|
||||||
|
GSList *files,
|
||||||
|
const GtkSourceEncoding *encoding,
|
||||||
|
gint line_pos,
|
||||||
|
gint column_pos) G_GNUC_WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
|
void _gedit_cmd_file_new (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data);
|
||||||
|
void _gedit_cmd_file_open (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data);
|
||||||
|
void _gedit_cmd_file_reopen_closed_tab (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data);
|
||||||
|
void _gedit_cmd_file_save (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data);
|
||||||
|
void _gedit_cmd_file_save_as (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data);
|
||||||
|
void _gedit_cmd_file_save_all (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data);
|
||||||
|
void _gedit_cmd_file_revert (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data);
|
||||||
|
void _gedit_cmd_file_print (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data);
|
||||||
|
void _gedit_cmd_file_close (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data);
|
||||||
|
void _gedit_cmd_file_close_all (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data);
|
||||||
|
void _gedit_cmd_file_close_window (GeditWindow *window);
|
||||||
|
void _gedit_cmd_file_quit (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void _gedit_cmd_edit_undo (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data);
|
||||||
|
void _gedit_cmd_edit_redo (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data);
|
||||||
|
void _gedit_cmd_edit_cut (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data);
|
||||||
|
void _gedit_cmd_edit_copy (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data);
|
||||||
|
void _gedit_cmd_edit_paste (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data);
|
||||||
|
void _gedit_cmd_edit_delete (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data);
|
||||||
|
void _gedit_cmd_edit_select_all (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data);
|
||||||
|
void _gedit_cmd_edit_overwrite_mode (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void _gedit_cmd_view_focus_active (GSimpleAction *action,
|
||||||
|
GVariant *state,
|
||||||
|
gpointer user_data);
|
||||||
|
void _gedit_cmd_view_toggle_side_panel (GSimpleAction *action,
|
||||||
|
GVariant *state,
|
||||||
|
gpointer user_data);
|
||||||
|
void _gedit_cmd_view_toggle_bottom_panel (GSimpleAction *action,
|
||||||
|
GVariant *state,
|
||||||
|
gpointer user_data);
|
||||||
|
void _gedit_cmd_view_toggle_fullscreen_mode (GSimpleAction *action,
|
||||||
|
GVariant *state,
|
||||||
|
gpointer user_data);
|
||||||
|
void _gedit_cmd_view_leave_fullscreen_mode (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data);
|
||||||
|
void _gedit_cmd_view_highlight_mode (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void _gedit_cmd_search_find (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data);
|
||||||
|
void _gedit_cmd_search_find_next (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data);
|
||||||
|
void _gedit_cmd_search_find_prev (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data);
|
||||||
|
void _gedit_cmd_search_replace (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data);
|
||||||
|
void _gedit_cmd_search_clear_highlight (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data);
|
||||||
|
void _gedit_cmd_search_goto_line (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void _gedit_cmd_documents_previous_document (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data);
|
||||||
|
void _gedit_cmd_documents_next_document (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data);
|
||||||
|
void _gedit_cmd_documents_move_to_new_window (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data);
|
||||||
|
void _gedit_cmd_documents_new_tab_group (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data);
|
||||||
|
void _gedit_cmd_documents_previous_tab_group (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data);
|
||||||
|
void _gedit_cmd_documents_next_tab_group (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
void _gedit_cmd_help_contents (GeditWindow *window);
|
||||||
|
void _gedit_cmd_help_about (GeditWindow *window);
|
||||||
|
|
||||||
|
void _gedit_cmd_file_close_tab (GeditTab *tab,
|
||||||
|
GeditWindow *window);
|
||||||
|
|
||||||
|
void _gedit_cmd_file_close_notebook (GeditWindow *window,
|
||||||
|
GeditNotebook *notebook);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* GEDIT_COMMANDS_PRIVATE_H */
|
||||||
|
/* ex:set ts=8 noet: */
|
718
gedit/gedit-commands-search.c
Normal file
|
@ -0,0 +1,718 @@
|
||||||
|
/*
|
||||||
|
* gedit-commands-search.c
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
|
||||||
|
* Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi
|
||||||
|
* Copyright (C) 2002-2006 Paolo Maggi
|
||||||
|
* Copyright (C) 2013 Sébastien Wilmet
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "gedit-commands.h"
|
||||||
|
#include "gedit-commands-private.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <glib/gi18n.h>
|
||||||
|
#include <gdk/gdkkeysyms.h>
|
||||||
|
#include <tepl/tepl.h>
|
||||||
|
|
||||||
|
#include "gedit-debug.h"
|
||||||
|
#include "gedit-statusbar.h"
|
||||||
|
#include "gedit-tab.h"
|
||||||
|
#include "gedit-tab-private.h"
|
||||||
|
#include "gedit-view-frame.h"
|
||||||
|
#include "gedit-window.h"
|
||||||
|
#include "gedit-utils.h"
|
||||||
|
#include "gedit-replace-dialog.h"
|
||||||
|
|
||||||
|
#define GEDIT_REPLACE_DIALOG_KEY "gedit-replace-dialog-key"
|
||||||
|
#define GEDIT_LAST_SEARCH_DATA_KEY "gedit-last-search-data-key"
|
||||||
|
|
||||||
|
typedef struct _LastSearchData LastSearchData;
|
||||||
|
struct _LastSearchData
|
||||||
|
{
|
||||||
|
gint x;
|
||||||
|
gint y;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
last_search_data_free (LastSearchData *data)
|
||||||
|
{
|
||||||
|
g_slice_free (LastSearchData, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
last_search_data_restore_position (GeditReplaceDialog *dlg)
|
||||||
|
{
|
||||||
|
LastSearchData *data;
|
||||||
|
|
||||||
|
data = g_object_get_data (G_OBJECT (dlg), GEDIT_LAST_SEARCH_DATA_KEY);
|
||||||
|
|
||||||
|
if (data != NULL)
|
||||||
|
{
|
||||||
|
gtk_window_move (GTK_WINDOW (dlg),
|
||||||
|
data->x,
|
||||||
|
data->y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
last_search_data_store_position (GeditReplaceDialog *dlg)
|
||||||
|
{
|
||||||
|
LastSearchData *data;
|
||||||
|
|
||||||
|
data = g_object_get_data (G_OBJECT (dlg), GEDIT_LAST_SEARCH_DATA_KEY);
|
||||||
|
|
||||||
|
if (data == NULL)
|
||||||
|
{
|
||||||
|
data = g_slice_new (LastSearchData);
|
||||||
|
|
||||||
|
g_object_set_data_full (G_OBJECT (dlg),
|
||||||
|
GEDIT_LAST_SEARCH_DATA_KEY,
|
||||||
|
data,
|
||||||
|
(GDestroyNotify) last_search_data_free);
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_window_get_position (GTK_WINDOW (dlg),
|
||||||
|
&data->x,
|
||||||
|
&data->y);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Use occurences only for Replace All */
|
||||||
|
static void
|
||||||
|
text_found (GeditWindow *window,
|
||||||
|
gint occurrences)
|
||||||
|
{
|
||||||
|
GeditStatusbar *statusbar = GEDIT_STATUSBAR (gedit_window_get_statusbar (window));
|
||||||
|
|
||||||
|
if (occurrences > 1)
|
||||||
|
{
|
||||||
|
_gedit_statusbar_flash_generic_message (statusbar,
|
||||||
|
ngettext("Found and replaced %d occurrence",
|
||||||
|
"Found and replaced %d occurrences",
|
||||||
|
occurrences),
|
||||||
|
occurrences);
|
||||||
|
}
|
||||||
|
else if (occurrences == 1)
|
||||||
|
{
|
||||||
|
_gedit_statusbar_flash_generic_message (statusbar,
|
||||||
|
_("Found and replaced one occurrence"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_gedit_statusbar_flash_generic_message (statusbar, " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define MAX_MSG_LENGTH 40
|
||||||
|
|
||||||
|
static void
|
||||||
|
text_not_found (GeditWindow *window,
|
||||||
|
GeditReplaceDialog *replace_dialog)
|
||||||
|
{
|
||||||
|
const gchar *search_text;
|
||||||
|
gchar *truncated_text;
|
||||||
|
GeditStatusbar *statusbar;
|
||||||
|
|
||||||
|
search_text = gedit_replace_dialog_get_search_text (replace_dialog);
|
||||||
|
truncated_text = tepl_utils_str_end_truncate (search_text, MAX_MSG_LENGTH);
|
||||||
|
|
||||||
|
statusbar = GEDIT_STATUSBAR (gedit_window_get_statusbar (window));
|
||||||
|
|
||||||
|
_gedit_statusbar_flash_generic_message (statusbar,
|
||||||
|
/* Translators: %s is replaced by the text entered
|
||||||
|
* by the user in the search box.
|
||||||
|
*/
|
||||||
|
_("“%s” not found"), truncated_text);
|
||||||
|
|
||||||
|
g_free (truncated_text);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
finish_search_from_dialog (GeditWindow *window,
|
||||||
|
gboolean found)
|
||||||
|
{
|
||||||
|
GeditReplaceDialog *replace_dialog;
|
||||||
|
|
||||||
|
replace_dialog = g_object_get_data (G_OBJECT (window), GEDIT_REPLACE_DIALOG_KEY);
|
||||||
|
|
||||||
|
g_return_if_fail (replace_dialog != NULL);
|
||||||
|
|
||||||
|
if (found)
|
||||||
|
{
|
||||||
|
text_found (window, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
text_not_found (window, replace_dialog);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
forward_search_finished (GtkSourceSearchContext *search_context,
|
||||||
|
GAsyncResult *result,
|
||||||
|
GeditView *view)
|
||||||
|
{
|
||||||
|
gboolean found;
|
||||||
|
GtkSourceBuffer *buffer;
|
||||||
|
GtkTextIter match_start;
|
||||||
|
GtkTextIter match_end;
|
||||||
|
|
||||||
|
found = gtk_source_search_context_forward_finish (search_context,
|
||||||
|
result,
|
||||||
|
&match_start,
|
||||||
|
&match_end,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
buffer = gtk_source_search_context_get_buffer (search_context);
|
||||||
|
|
||||||
|
if (found)
|
||||||
|
{
|
||||||
|
gtk_text_buffer_select_range (GTK_TEXT_BUFFER (buffer),
|
||||||
|
&match_start,
|
||||||
|
&match_end);
|
||||||
|
|
||||||
|
tepl_view_scroll_to_cursor (TEPL_VIEW (view));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GtkTextIter end_selection;
|
||||||
|
|
||||||
|
gtk_text_buffer_get_selection_bounds (GTK_TEXT_BUFFER (buffer),
|
||||||
|
NULL,
|
||||||
|
&end_selection);
|
||||||
|
|
||||||
|
gtk_text_buffer_select_range (GTK_TEXT_BUFFER (buffer),
|
||||||
|
&end_selection,
|
||||||
|
&end_selection);
|
||||||
|
}
|
||||||
|
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
forward_search_from_dialog_finished (GtkSourceSearchContext *search_context,
|
||||||
|
GAsyncResult *result,
|
||||||
|
GeditWindow *window)
|
||||||
|
{
|
||||||
|
GeditView *view = gedit_window_get_active_view (window);
|
||||||
|
gboolean found;
|
||||||
|
|
||||||
|
if (view == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
found = forward_search_finished (search_context, result, view);
|
||||||
|
|
||||||
|
finish_search_from_dialog (window, found);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
forward_search_finished_cb (GObject *source_object,
|
||||||
|
GAsyncResult *result,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GtkSourceSearchContext *search_context = GTK_SOURCE_SEARCH_CONTEXT (source_object);
|
||||||
|
GeditView *view = GEDIT_VIEW (user_data);
|
||||||
|
|
||||||
|
forward_search_finished (search_context, result, view);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
run_forward_search (GeditWindow *window,
|
||||||
|
gboolean from_dialog)
|
||||||
|
{
|
||||||
|
GeditView *view;
|
||||||
|
GtkTextBuffer *buffer;
|
||||||
|
GtkTextIter start_at;
|
||||||
|
GtkSourceSearchContext *search_context;
|
||||||
|
|
||||||
|
view = gedit_window_get_active_view (window);
|
||||||
|
|
||||||
|
if (view == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||||
|
|
||||||
|
search_context = gedit_document_get_search_context (GEDIT_DOCUMENT (buffer));
|
||||||
|
|
||||||
|
if (search_context == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_text_buffer_get_selection_bounds (buffer, NULL, &start_at);
|
||||||
|
|
||||||
|
if (from_dialog)
|
||||||
|
{
|
||||||
|
gtk_source_search_context_forward_async (search_context,
|
||||||
|
&start_at,
|
||||||
|
NULL,
|
||||||
|
(GAsyncReadyCallback)forward_search_from_dialog_finished,
|
||||||
|
window);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gtk_source_search_context_forward_async (search_context,
|
||||||
|
&start_at,
|
||||||
|
NULL,
|
||||||
|
forward_search_finished_cb,
|
||||||
|
view);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
backward_search_finished (GtkSourceSearchContext *search_context,
|
||||||
|
GAsyncResult *result,
|
||||||
|
GeditView *view)
|
||||||
|
{
|
||||||
|
gboolean found;
|
||||||
|
GtkTextIter match_start;
|
||||||
|
GtkTextIter match_end;
|
||||||
|
GtkSourceBuffer *buffer;
|
||||||
|
|
||||||
|
found = gtk_source_search_context_backward_finish (search_context,
|
||||||
|
result,
|
||||||
|
&match_start,
|
||||||
|
&match_end,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
buffer = gtk_source_search_context_get_buffer (search_context);
|
||||||
|
|
||||||
|
if (found)
|
||||||
|
{
|
||||||
|
gtk_text_buffer_select_range (GTK_TEXT_BUFFER (buffer),
|
||||||
|
&match_start,
|
||||||
|
&match_end);
|
||||||
|
|
||||||
|
tepl_view_scroll_to_cursor (TEPL_VIEW (view));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GtkTextIter start_selection;
|
||||||
|
|
||||||
|
gtk_text_buffer_get_selection_bounds (GTK_TEXT_BUFFER (buffer),
|
||||||
|
&start_selection,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
gtk_text_buffer_select_range (GTK_TEXT_BUFFER (buffer),
|
||||||
|
&start_selection,
|
||||||
|
&start_selection);
|
||||||
|
}
|
||||||
|
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
backward_search_from_dialog_finished (GtkSourceSearchContext *search_context,
|
||||||
|
GAsyncResult *result,
|
||||||
|
GeditWindow *window)
|
||||||
|
{
|
||||||
|
GeditView *view = gedit_window_get_active_view (window);
|
||||||
|
gboolean found;
|
||||||
|
|
||||||
|
if (view == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
found = backward_search_finished (search_context, result, view);
|
||||||
|
|
||||||
|
finish_search_from_dialog (window, found);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
backward_search_finished_cb (GObject *source_object,
|
||||||
|
GAsyncResult *result,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GtkSourceSearchContext *search_context = GTK_SOURCE_SEARCH_CONTEXT (source_object);
|
||||||
|
GeditView *view = GEDIT_VIEW (user_data);
|
||||||
|
|
||||||
|
backward_search_finished (search_context, result, view);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
run_backward_search (GeditWindow *window,
|
||||||
|
gboolean from_dialog)
|
||||||
|
{
|
||||||
|
GeditView *view;
|
||||||
|
GtkTextBuffer *buffer;
|
||||||
|
GtkTextIter start_at;
|
||||||
|
GtkSourceSearchContext *search_context;
|
||||||
|
|
||||||
|
view = gedit_window_get_active_view (window);
|
||||||
|
|
||||||
|
if (view == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||||
|
|
||||||
|
search_context = gedit_document_get_search_context (GEDIT_DOCUMENT (buffer));
|
||||||
|
|
||||||
|
if (search_context == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_text_buffer_get_selection_bounds (buffer, &start_at, NULL);
|
||||||
|
|
||||||
|
if (from_dialog)
|
||||||
|
{
|
||||||
|
gtk_source_search_context_backward_async (search_context,
|
||||||
|
&start_at,
|
||||||
|
NULL,
|
||||||
|
(GAsyncReadyCallback)backward_search_from_dialog_finished,
|
||||||
|
window);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gtk_source_search_context_backward_async (search_context,
|
||||||
|
&start_at,
|
||||||
|
NULL,
|
||||||
|
backward_search_finished_cb,
|
||||||
|
view);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
do_find (GeditReplaceDialog *dialog,
|
||||||
|
GeditWindow *window)
|
||||||
|
{
|
||||||
|
if (gedit_replace_dialog_get_backwards (dialog))
|
||||||
|
{
|
||||||
|
run_backward_search (window, TRUE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
run_forward_search (window, TRUE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
do_replace (GeditReplaceDialog *dialog,
|
||||||
|
GeditWindow *window)
|
||||||
|
{
|
||||||
|
GeditDocument *doc;
|
||||||
|
GtkSourceSearchContext *search_context;
|
||||||
|
const gchar *replace_entry_text;
|
||||||
|
gchar *unescaped_replace_text;
|
||||||
|
GtkTextIter start;
|
||||||
|
GtkTextIter end;
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
doc = gedit_window_get_active_document (window);
|
||||||
|
|
||||||
|
if (doc == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
search_context = gedit_document_get_search_context (doc);
|
||||||
|
|
||||||
|
if (search_context == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* replace text may be "", we just delete */
|
||||||
|
replace_entry_text = gedit_replace_dialog_get_replace_text (dialog);
|
||||||
|
g_return_if_fail (replace_entry_text != NULL);
|
||||||
|
|
||||||
|
unescaped_replace_text = gtk_source_utils_unescape_search_text (replace_entry_text);
|
||||||
|
|
||||||
|
gtk_text_buffer_get_selection_bounds (GTK_TEXT_BUFFER (doc), &start, &end);
|
||||||
|
|
||||||
|
gtk_source_search_context_replace (search_context,
|
||||||
|
&start,
|
||||||
|
&end,
|
||||||
|
unescaped_replace_text,
|
||||||
|
-1,
|
||||||
|
&error);
|
||||||
|
|
||||||
|
g_free (unescaped_replace_text);
|
||||||
|
|
||||||
|
if (error != NULL)
|
||||||
|
{
|
||||||
|
gedit_replace_dialog_set_replace_error (dialog, error->message);
|
||||||
|
g_error_free (error);
|
||||||
|
}
|
||||||
|
|
||||||
|
do_find (dialog, window);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
do_replace_all (GeditReplaceDialog *dialog,
|
||||||
|
GeditWindow *window)
|
||||||
|
{
|
||||||
|
GeditView *view;
|
||||||
|
GtkSourceSearchContext *search_context;
|
||||||
|
GtkTextBuffer *buffer;
|
||||||
|
GtkSourceCompletion *completion;
|
||||||
|
const gchar *replace_entry_text;
|
||||||
|
gchar *unescaped_replace_text;
|
||||||
|
gint count;
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
view = gedit_window_get_active_view (window);
|
||||||
|
|
||||||
|
if (view == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
|
||||||
|
|
||||||
|
search_context = gedit_document_get_search_context (GEDIT_DOCUMENT (buffer));
|
||||||
|
|
||||||
|
if (search_context == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* FIXME: this should really be done automatically in gtksoureview, but
|
||||||
|
* it is an important performance fix, so let's do it here for now.
|
||||||
|
*/
|
||||||
|
completion = gtk_source_view_get_completion (GTK_SOURCE_VIEW (view));
|
||||||
|
gtk_source_completion_block_interactive (completion);
|
||||||
|
|
||||||
|
/* replace text may be "", we just delete all occurrences */
|
||||||
|
replace_entry_text = gedit_replace_dialog_get_replace_text (dialog);
|
||||||
|
g_return_if_fail (replace_entry_text != NULL);
|
||||||
|
|
||||||
|
unescaped_replace_text = gtk_source_utils_unescape_search_text (replace_entry_text);
|
||||||
|
|
||||||
|
count = gtk_source_search_context_replace_all (search_context,
|
||||||
|
unescaped_replace_text,
|
||||||
|
-1,
|
||||||
|
&error);
|
||||||
|
|
||||||
|
g_free (unescaped_replace_text);
|
||||||
|
|
||||||
|
gtk_source_completion_unblock_interactive (completion);
|
||||||
|
|
||||||
|
if (count > 0)
|
||||||
|
{
|
||||||
|
text_found (window, count);
|
||||||
|
}
|
||||||
|
else if (error == NULL)
|
||||||
|
{
|
||||||
|
text_not_found (window, dialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error != NULL)
|
||||||
|
{
|
||||||
|
gedit_replace_dialog_set_replace_error (dialog, error->message);
|
||||||
|
g_error_free (error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
replace_dialog_response_cb (GeditReplaceDialog *dialog,
|
||||||
|
gint response_id,
|
||||||
|
GeditWindow *window)
|
||||||
|
{
|
||||||
|
gedit_debug (DEBUG_COMMANDS);
|
||||||
|
|
||||||
|
switch (response_id)
|
||||||
|
{
|
||||||
|
case GEDIT_REPLACE_DIALOG_FIND_RESPONSE:
|
||||||
|
do_find (dialog, window);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GEDIT_REPLACE_DIALOG_REPLACE_RESPONSE:
|
||||||
|
do_replace (dialog, window);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GEDIT_REPLACE_DIALOG_REPLACE_ALL_RESPONSE:
|
||||||
|
do_replace_all (dialog, window);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
last_search_data_store_position (dialog);
|
||||||
|
gtk_widget_hide (GTK_WIDGET (dialog));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
replace_dialog_destroyed (GeditWindow *window,
|
||||||
|
GeditReplaceDialog *dialog)
|
||||||
|
{
|
||||||
|
gedit_debug (DEBUG_COMMANDS);
|
||||||
|
|
||||||
|
g_object_set_data (G_OBJECT (window),
|
||||||
|
GEDIT_REPLACE_DIALOG_KEY,
|
||||||
|
NULL);
|
||||||
|
g_object_set_data (G_OBJECT (dialog),
|
||||||
|
GEDIT_LAST_SEARCH_DATA_KEY,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static GtkWidget *
|
||||||
|
create_dialog (GeditWindow *window)
|
||||||
|
{
|
||||||
|
GtkWidget *dialog = gedit_replace_dialog_new (window);
|
||||||
|
|
||||||
|
g_signal_connect (dialog,
|
||||||
|
"response",
|
||||||
|
G_CALLBACK (replace_dialog_response_cb),
|
||||||
|
window);
|
||||||
|
|
||||||
|
g_object_set_data (G_OBJECT (window),
|
||||||
|
GEDIT_REPLACE_DIALOG_KEY,
|
||||||
|
dialog);
|
||||||
|
|
||||||
|
g_object_weak_ref (G_OBJECT (dialog),
|
||||||
|
(GWeakNotify) replace_dialog_destroyed,
|
||||||
|
window);
|
||||||
|
|
||||||
|
return dialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gedit_cmd_search_find (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GeditWindow *window = GEDIT_WINDOW (user_data);
|
||||||
|
GeditTab *active_tab;
|
||||||
|
GeditViewFrame *frame;
|
||||||
|
|
||||||
|
gedit_debug (DEBUG_COMMANDS);
|
||||||
|
|
||||||
|
active_tab = gedit_window_get_active_tab (window);
|
||||||
|
|
||||||
|
if (active_tab == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
frame = _gedit_tab_get_view_frame (active_tab);
|
||||||
|
gedit_view_frame_popup_search (frame);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gedit_cmd_search_replace (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GeditWindow *window = GEDIT_WINDOW (user_data);
|
||||||
|
gpointer data;
|
||||||
|
GtkWidget *replace_dialog;
|
||||||
|
|
||||||
|
gedit_debug (DEBUG_COMMANDS);
|
||||||
|
|
||||||
|
data = g_object_get_data (G_OBJECT (window), GEDIT_REPLACE_DIALOG_KEY);
|
||||||
|
|
||||||
|
if (data == NULL)
|
||||||
|
{
|
||||||
|
replace_dialog = create_dialog (window);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_return_if_fail (GEDIT_IS_REPLACE_DIALOG (data));
|
||||||
|
|
||||||
|
replace_dialog = GTK_WIDGET (data);
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_widget_show (replace_dialog);
|
||||||
|
last_search_data_restore_position (GEDIT_REPLACE_DIALOG (replace_dialog));
|
||||||
|
gedit_replace_dialog_present_with_time (GEDIT_REPLACE_DIALOG (replace_dialog),
|
||||||
|
GDK_CURRENT_TIME);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gedit_cmd_search_find_next (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GeditWindow *window = GEDIT_WINDOW (user_data);
|
||||||
|
|
||||||
|
gedit_debug (DEBUG_COMMANDS);
|
||||||
|
|
||||||
|
run_forward_search (window, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gedit_cmd_search_find_prev (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GeditWindow *window = GEDIT_WINDOW (user_data);
|
||||||
|
|
||||||
|
gedit_debug (DEBUG_COMMANDS);
|
||||||
|
|
||||||
|
run_backward_search (window, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gedit_cmd_search_clear_highlight (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GeditWindow *window = GEDIT_WINDOW (user_data);
|
||||||
|
GeditTab *active_tab;
|
||||||
|
GeditViewFrame *frame;
|
||||||
|
GeditDocument *doc;
|
||||||
|
|
||||||
|
gedit_debug (DEBUG_COMMANDS);
|
||||||
|
|
||||||
|
active_tab = gedit_window_get_active_tab (window);
|
||||||
|
|
||||||
|
if (active_tab == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
frame = _gedit_tab_get_view_frame (active_tab);
|
||||||
|
gedit_view_frame_clear_search (frame);
|
||||||
|
|
||||||
|
doc = gedit_tab_get_document (active_tab);
|
||||||
|
gedit_document_set_search_context (doc, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gedit_cmd_search_goto_line (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GeditWindow *window = GEDIT_WINDOW (user_data);
|
||||||
|
GeditTab *active_tab;
|
||||||
|
GeditViewFrame *frame;
|
||||||
|
|
||||||
|
gedit_debug (DEBUG_COMMANDS);
|
||||||
|
|
||||||
|
active_tab = gedit_window_get_active_tab (window);
|
||||||
|
|
||||||
|
if (active_tab == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
frame = _gedit_tab_get_view_frame (active_tab);
|
||||||
|
gedit_view_frame_popup_goto_line (frame);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ex:set ts=8 noet: */
|
175
gedit/gedit-commands-view.c
Normal file
|
@ -0,0 +1,175 @@
|
||||||
|
/*
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
|
||||||
|
* Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi
|
||||||
|
* Copyright (C) 2002-2005 Paolo Maggi
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "gedit-commands-private.h"
|
||||||
|
#include <tepl/tepl.h>
|
||||||
|
#include "gedit-window-private.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
_gedit_cmd_view_focus_active (GSimpleAction *action,
|
||||||
|
GVariant *state,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GeditWindow *window = GEDIT_WINDOW (user_data);
|
||||||
|
GeditView *active_view;
|
||||||
|
|
||||||
|
active_view = gedit_window_get_active_view (window);
|
||||||
|
|
||||||
|
if (active_view != NULL)
|
||||||
|
{
|
||||||
|
gtk_widget_grab_focus (GTK_WIDGET (active_view));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gedit_cmd_view_toggle_side_panel (GSimpleAction *action,
|
||||||
|
GVariant *state,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GeditWindow *window = GEDIT_WINDOW (user_data);
|
||||||
|
GeditSidePanel *panel;
|
||||||
|
gboolean visible;
|
||||||
|
|
||||||
|
panel = _gedit_window_get_whole_side_panel (window);
|
||||||
|
|
||||||
|
visible = g_variant_get_boolean (state);
|
||||||
|
gtk_widget_set_visible (GTK_WIDGET (panel), visible);
|
||||||
|
|
||||||
|
/* TODO: either remove this code, or make it work as desired. */
|
||||||
|
#if 0
|
||||||
|
if (visible)
|
||||||
|
{
|
||||||
|
gtk_widget_grab_focus (GTK_WIDGET (panel));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
g_simple_action_set_state (action, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gedit_cmd_view_toggle_bottom_panel (GSimpleAction *action,
|
||||||
|
GVariant *state,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GeditWindow *window = GEDIT_WINDOW (user_data);
|
||||||
|
GeditBottomPanel *panel;
|
||||||
|
gboolean visible;
|
||||||
|
|
||||||
|
panel = _gedit_window_get_whole_bottom_panel (window);
|
||||||
|
|
||||||
|
visible = g_variant_get_boolean (state);
|
||||||
|
gtk_widget_set_visible (GTK_WIDGET (panel), visible);
|
||||||
|
|
||||||
|
/* TODO: either remove this code, or make it work as desired. */
|
||||||
|
#if 0
|
||||||
|
if (visible)
|
||||||
|
{
|
||||||
|
gtk_widget_grab_focus (GTK_WIDGET (panel));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
g_simple_action_set_state (action, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gedit_cmd_view_toggle_fullscreen_mode (GSimpleAction *action,
|
||||||
|
GVariant *state,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GeditWindow *window = GEDIT_WINDOW (user_data);
|
||||||
|
|
||||||
|
if (g_variant_get_boolean (state))
|
||||||
|
{
|
||||||
|
_gedit_window_fullscreen (window);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_gedit_window_unfullscreen (window);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gedit_cmd_view_leave_fullscreen_mode (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
_gedit_window_unfullscreen (GEDIT_WINDOW (user_data));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
language_activated_cb (TeplLanguageChooserDialog *dialog,
|
||||||
|
GtkSourceLanguage *language,
|
||||||
|
GeditWindow *window)
|
||||||
|
{
|
||||||
|
GeditDocument *active_document;
|
||||||
|
|
||||||
|
active_document = gedit_window_get_active_document (window);
|
||||||
|
if (active_document != NULL)
|
||||||
|
{
|
||||||
|
gedit_document_set_language (active_document, language);
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_widget_destroy (GTK_WIDGET (dialog));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
language_chooser_dialog_response_after_cb (TeplLanguageChooserDialog *dialog,
|
||||||
|
gint response_id,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
gtk_widget_destroy (GTK_WIDGET (dialog));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_gedit_cmd_view_highlight_mode (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GeditWindow *window = GEDIT_WINDOW (user_data);
|
||||||
|
TeplLanguageChooserDialog *dialog;
|
||||||
|
GeditDocument *active_document;
|
||||||
|
|
||||||
|
dialog = tepl_language_chooser_dialog_new (GTK_WINDOW (window));
|
||||||
|
|
||||||
|
active_document = gedit_window_get_active_document (window);
|
||||||
|
if (active_document != NULL)
|
||||||
|
{
|
||||||
|
GtkSourceLanguage *language;
|
||||||
|
|
||||||
|
language = gtk_source_buffer_get_language (GTK_SOURCE_BUFFER (active_document));
|
||||||
|
tepl_language_chooser_select_language (TEPL_LANGUAGE_CHOOSER (dialog), language);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_signal_connect_object (dialog,
|
||||||
|
"language-activated",
|
||||||
|
G_CALLBACK (language_activated_cb),
|
||||||
|
window,
|
||||||
|
G_CONNECT_DEFAULT);
|
||||||
|
|
||||||
|
g_signal_connect_after (dialog,
|
||||||
|
"response",
|
||||||
|
G_CALLBACK (language_chooser_dialog_response_after_cb),
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
gtk_widget_show (GTK_WIDGET (dialog));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ex:set ts=8 noet: */
|
63
gedit/gedit-commands.h
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
|
||||||
|
/*
|
||||||
|
* gedit-commands.h
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
|
||||||
|
* Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi
|
||||||
|
* Copyright (C) 2002-2005 Paolo Maggi
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GEDIT_COMMANDS_H
|
||||||
|
#define GEDIT_COMMANDS_H
|
||||||
|
|
||||||
|
#include <gtksourceview/gtksource.h>
|
||||||
|
#include <gedit/gedit-window.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
/* Do nothing if URI does not exist */
|
||||||
|
void gedit_commands_load_location (GeditWindow *window,
|
||||||
|
GFile *location,
|
||||||
|
const GtkSourceEncoding *encoding,
|
||||||
|
gint line_pos,
|
||||||
|
gint column_pos);
|
||||||
|
|
||||||
|
/* Ignore non-existing URIs */
|
||||||
|
GSList *gedit_commands_load_locations (GeditWindow *window,
|
||||||
|
const GSList *locations,
|
||||||
|
const GtkSourceEncoding *encoding,
|
||||||
|
gint line_pos,
|
||||||
|
gint column_pos) G_GNUC_WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
|
void gedit_commands_save_document (GeditWindow *window,
|
||||||
|
GeditDocument *document);
|
||||||
|
|
||||||
|
void gedit_commands_save_document_async (GeditDocument *document,
|
||||||
|
GeditWindow *window,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GAsyncReadyCallback callback,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
gboolean gedit_commands_save_document_finish (GeditDocument *document,
|
||||||
|
GAsyncResult *result);
|
||||||
|
|
||||||
|
void gedit_commands_save_all_documents (GeditWindow *window);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* GEDIT_COMMANDS_H */
|
||||||
|
/* ex:set ts=8 noet: */
|
227
gedit/gedit-debug.c
Normal file
|
@ -0,0 +1,227 @@
|
||||||
|
/*
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
|
||||||
|
* Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi
|
||||||
|
* Copyright (C) 2002 - 2005 Paolo Maggi
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "gedit-debug.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#define ENABLE_PROFILING
|
||||||
|
|
||||||
|
#ifdef ENABLE_PROFILING
|
||||||
|
static GTimer *timer = NULL;
|
||||||
|
static gdouble last_time = 0.0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static GeditDebugSection enabled_sections = GEDIT_NO_DEBUG;
|
||||||
|
|
||||||
|
#define DEBUG_IS_ENABLED(section) (enabled_sections & (section))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gedit_debug_init:
|
||||||
|
*
|
||||||
|
* Initializes the debugging subsystem of gedit.
|
||||||
|
*
|
||||||
|
* The function checks for the existence of certain environment variables to
|
||||||
|
* determine whether to enable output for a debug section. To enable output
|
||||||
|
* for a specific debug section, set an environment variable of the same name;
|
||||||
|
* e.g. to enable output for the %GEDIT_DEBUG_PLUGINS section, set a
|
||||||
|
* <code>GEDIT_DEBUG_PLUGINS</code> environment variable. To enable output
|
||||||
|
* for all debug sections, set the <code>GEDIT_DEBUG</code> environment
|
||||||
|
* variable.
|
||||||
|
*
|
||||||
|
* This function must be called before any of the other debug functions are
|
||||||
|
* called. It must only be called once.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gedit_debug_init (void)
|
||||||
|
{
|
||||||
|
if (g_getenv ("GEDIT_DEBUG") != NULL)
|
||||||
|
{
|
||||||
|
/* enable all debugging */
|
||||||
|
enabled_sections = ~GEDIT_NO_DEBUG;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_getenv ("GEDIT_DEBUG_PREFS") != NULL)
|
||||||
|
{
|
||||||
|
enabled_sections |= GEDIT_DEBUG_PREFS;
|
||||||
|
}
|
||||||
|
if (g_getenv ("GEDIT_DEBUG_WINDOW") != NULL)
|
||||||
|
{
|
||||||
|
enabled_sections |= GEDIT_DEBUG_WINDOW;
|
||||||
|
}
|
||||||
|
if (g_getenv ("GEDIT_DEBUG_PANEL") != NULL)
|
||||||
|
{
|
||||||
|
enabled_sections |= GEDIT_DEBUG_PANEL;
|
||||||
|
}
|
||||||
|
if (g_getenv ("GEDIT_DEBUG_PLUGINS") != NULL)
|
||||||
|
{
|
||||||
|
enabled_sections |= GEDIT_DEBUG_PLUGINS;
|
||||||
|
}
|
||||||
|
if (g_getenv ("GEDIT_DEBUG_TAB") != NULL)
|
||||||
|
{
|
||||||
|
enabled_sections |= GEDIT_DEBUG_TAB;
|
||||||
|
}
|
||||||
|
if (g_getenv ("GEDIT_DEBUG_DOCUMENT") != NULL)
|
||||||
|
{
|
||||||
|
enabled_sections |= GEDIT_DEBUG_DOCUMENT;
|
||||||
|
}
|
||||||
|
if (g_getenv ("GEDIT_DEBUG_COMMANDS") != NULL)
|
||||||
|
{
|
||||||
|
enabled_sections |= GEDIT_DEBUG_COMMANDS;
|
||||||
|
}
|
||||||
|
if (g_getenv ("GEDIT_DEBUG_APP") != NULL)
|
||||||
|
{
|
||||||
|
enabled_sections |= GEDIT_DEBUG_APP;
|
||||||
|
}
|
||||||
|
if (g_getenv ("GEDIT_DEBUG_UTILS") != NULL)
|
||||||
|
{
|
||||||
|
enabled_sections |= GEDIT_DEBUG_UTILS;
|
||||||
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
|
|
||||||
|
#ifdef ENABLE_PROFILING
|
||||||
|
if (enabled_sections != GEDIT_NO_DEBUG)
|
||||||
|
{
|
||||||
|
timer = g_timer_new ();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gedit_debug:
|
||||||
|
* @section: debug section.
|
||||||
|
* @file: file name.
|
||||||
|
* @line: line number.
|
||||||
|
* @function: name of the function that is calling gedit_debug().
|
||||||
|
*
|
||||||
|
* If @section is enabled, then logs the trace information @file, @line, and
|
||||||
|
* @function.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gedit_debug (GeditDebugSection section,
|
||||||
|
const gchar *file,
|
||||||
|
gint line,
|
||||||
|
const gchar *function)
|
||||||
|
{
|
||||||
|
gedit_debug_message (section, file, line, function, "%s", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gedit_debug_message:
|
||||||
|
* @section: debug section.
|
||||||
|
* @file: file name.
|
||||||
|
* @line: line number.
|
||||||
|
* @function: name of the function that is calling gedit_debug_message().
|
||||||
|
* @format: A g_vprintf() format string.
|
||||||
|
* @...: The format string arguments.
|
||||||
|
*
|
||||||
|
* If @section is enabled, then logs the trace information @file, @line, and
|
||||||
|
* @function along with the message obtained by formatting @format with the
|
||||||
|
* given format string arguments.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gedit_debug_message (GeditDebugSection section,
|
||||||
|
const gchar *file,
|
||||||
|
gint line,
|
||||||
|
const gchar *function,
|
||||||
|
const gchar *format,
|
||||||
|
...)
|
||||||
|
{
|
||||||
|
if (G_UNLIKELY (DEBUG_IS_ENABLED (section)))
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
gchar *msg;
|
||||||
|
|
||||||
|
#ifdef ENABLE_PROFILING
|
||||||
|
gdouble seconds;
|
||||||
|
|
||||||
|
g_return_if_fail (timer != NULL);
|
||||||
|
|
||||||
|
seconds = g_timer_elapsed (timer, NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
g_return_if_fail (format != NULL);
|
||||||
|
|
||||||
|
va_start (args, format);
|
||||||
|
msg = g_strdup_vprintf (format, args);
|
||||||
|
va_end (args);
|
||||||
|
|
||||||
|
#ifdef ENABLE_PROFILING
|
||||||
|
g_print ("[%f (%f)] %s:%d (%s) %s\n",
|
||||||
|
seconds,
|
||||||
|
seconds - last_time,
|
||||||
|
file,
|
||||||
|
line,
|
||||||
|
function,
|
||||||
|
msg);
|
||||||
|
|
||||||
|
last_time = seconds;
|
||||||
|
#else
|
||||||
|
g_print ("%s:%d (%s) %s\n", file, line, function, msg);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
fflush (stdout);
|
||||||
|
|
||||||
|
g_free (msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gedit_debug_plugin_message:
|
||||||
|
* @file: file name.
|
||||||
|
* @line: line number.
|
||||||
|
* @function: name of the function that is calling gedit_debug_plugin_message().
|
||||||
|
* @message: a message.
|
||||||
|
*
|
||||||
|
* If the section %GEDIT_DEBUG_PLUGINS is enabled, then logs the trace
|
||||||
|
* information @file, @line, and @function along with @message.
|
||||||
|
*
|
||||||
|
* This function may be overridden by GObject Introspection language bindings
|
||||||
|
* to be more language-specific.
|
||||||
|
*
|
||||||
|
* <emphasis>Python</emphasis>
|
||||||
|
*
|
||||||
|
* A PyGObject override is provided that has the following signature:
|
||||||
|
* <informalexample>
|
||||||
|
* <programlisting>
|
||||||
|
* def debug_plugin_message(format_str, *format_args):
|
||||||
|
* #...
|
||||||
|
* </programlisting>
|
||||||
|
* </informalexample>
|
||||||
|
*
|
||||||
|
* It automatically supplies parameters @file, @line, and @function, and it
|
||||||
|
* formats <code>format_str</code> with the given format arguments. The syntax
|
||||||
|
* of the format string is the usual Python string formatting syntax described
|
||||||
|
* by <ulink url="http://docs.python.org/library/stdtypes.html#string-formatting">5.6.2. String Formatting Operations</ulink>.
|
||||||
|
*
|
||||||
|
* Since: 3.4
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gedit_debug_plugin_message (const gchar *file,
|
||||||
|
gint line,
|
||||||
|
const gchar *function,
|
||||||
|
const gchar *message)
|
||||||
|
{
|
||||||
|
gedit_debug_message (GEDIT_DEBUG_PLUGINS, file, line, function, "%s", message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ex:set ts=8 noet: */
|
80
gedit/gedit-debug.h
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
/*
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
|
||||||
|
* Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi
|
||||||
|
* Copyright (C) 2002 - 2005 Paolo Maggi
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GEDIT_DEBUG_H
|
||||||
|
#define GEDIT_DEBUG_H
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GeditDebugSection:
|
||||||
|
*
|
||||||
|
* Enumeration of debug sections.
|
||||||
|
*
|
||||||
|
* Debugging output for a section is enabled by setting an environment variable
|
||||||
|
* of the same name. For example, setting the <code>GEDIT_DEBUG_PLUGINS</code>
|
||||||
|
* environment variable enables all debugging output for the %GEDIT_DEBUG_PLUGINS
|
||||||
|
* section. Setting the special environment variable <code>GEDIT_DEBUG</code>
|
||||||
|
* enables output for all sections.
|
||||||
|
*/
|
||||||
|
typedef enum {
|
||||||
|
GEDIT_NO_DEBUG = 0,
|
||||||
|
GEDIT_DEBUG_PREFS = 1 << 0,
|
||||||
|
GEDIT_DEBUG_WINDOW = 1 << 1,
|
||||||
|
GEDIT_DEBUG_PANEL = 1 << 2,
|
||||||
|
GEDIT_DEBUG_PLUGINS = 1 << 3,
|
||||||
|
GEDIT_DEBUG_TAB = 1 << 4,
|
||||||
|
GEDIT_DEBUG_DOCUMENT = 1 << 5,
|
||||||
|
GEDIT_DEBUG_COMMANDS = 1 << 6,
|
||||||
|
GEDIT_DEBUG_APP = 1 << 7,
|
||||||
|
GEDIT_DEBUG_UTILS = 1 << 8,
|
||||||
|
} GeditDebugSection;
|
||||||
|
|
||||||
|
#define DEBUG_PREFS GEDIT_DEBUG_PREFS, __FILE__, __LINE__, G_STRFUNC
|
||||||
|
#define DEBUG_WINDOW GEDIT_DEBUG_WINDOW, __FILE__, __LINE__, G_STRFUNC
|
||||||
|
#define DEBUG_PANEL GEDIT_DEBUG_PANEL, __FILE__, __LINE__, G_STRFUNC
|
||||||
|
#define DEBUG_PLUGINS GEDIT_DEBUG_PLUGINS, __FILE__, __LINE__, G_STRFUNC
|
||||||
|
#define DEBUG_TAB GEDIT_DEBUG_TAB, __FILE__, __LINE__, G_STRFUNC
|
||||||
|
#define DEBUG_DOCUMENT GEDIT_DEBUG_DOCUMENT,__FILE__, __LINE__, G_STRFUNC
|
||||||
|
#define DEBUG_COMMANDS GEDIT_DEBUG_COMMANDS,__FILE__, __LINE__, G_STRFUNC
|
||||||
|
#define DEBUG_APP GEDIT_DEBUG_APP, __FILE__, __LINE__, G_STRFUNC
|
||||||
|
#define DEBUG_UTILS GEDIT_DEBUG_UTILS, __FILE__, __LINE__, G_STRFUNC
|
||||||
|
|
||||||
|
void gedit_debug_init (void);
|
||||||
|
|
||||||
|
void gedit_debug (GeditDebugSection section,
|
||||||
|
const gchar *file,
|
||||||
|
gint line,
|
||||||
|
const gchar *function);
|
||||||
|
|
||||||
|
void gedit_debug_message (GeditDebugSection section,
|
||||||
|
const gchar *file,
|
||||||
|
gint line,
|
||||||
|
const gchar *function,
|
||||||
|
const gchar *format, ...) G_GNUC_PRINTF(5, 6);
|
||||||
|
|
||||||
|
void gedit_debug_plugin_message (const gchar *file,
|
||||||
|
gint line,
|
||||||
|
const gchar *function,
|
||||||
|
const gchar *message);
|
||||||
|
|
||||||
|
#endif /* GEDIT_DEBUG_H */
|
||||||
|
/* ex:set ts=8 noet: */
|
161
gedit/gedit-dirs.c
Normal file
|
@ -0,0 +1,161 @@
|
||||||
|
/*
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008 Ignacio Casal Quinteiro
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "gedit-dirs.h"
|
||||||
|
|
||||||
|
#if OS_MACOS
|
||||||
|
#include <gtkosxapplication.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static gchar *user_config_dir = NULL;
|
||||||
|
static gchar *user_data_dir = NULL;
|
||||||
|
static gchar *user_plugins_dir = NULL;
|
||||||
|
static gchar *gedit_locale_dir = NULL;
|
||||||
|
static gchar *gedit_lib_dir = NULL;
|
||||||
|
static gchar *gedit_plugins_dir = NULL;
|
||||||
|
static gchar *gedit_plugins_data_dir = NULL;
|
||||||
|
|
||||||
|
void
|
||||||
|
gedit_dirs_init (void)
|
||||||
|
{
|
||||||
|
#ifdef G_OS_WIN32
|
||||||
|
gchar *win32_dir;
|
||||||
|
|
||||||
|
win32_dir = g_win32_get_package_installation_directory_of_module (NULL);
|
||||||
|
|
||||||
|
gedit_locale_dir = g_build_filename (win32_dir,
|
||||||
|
"share",
|
||||||
|
"locale",
|
||||||
|
NULL);
|
||||||
|
gedit_lib_dir = g_build_filename (win32_dir,
|
||||||
|
"lib",
|
||||||
|
"gedit",
|
||||||
|
NULL);
|
||||||
|
gedit_plugins_data_dir = g_build_filename (win32_dir,
|
||||||
|
"share",
|
||||||
|
"gedit",
|
||||||
|
"plugins",
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
g_free (win32_dir);
|
||||||
|
#endif /* G_OS_WIN32 */
|
||||||
|
|
||||||
|
#if OS_MACOS
|
||||||
|
if (gtkosx_application_get_bundle_id () != NULL)
|
||||||
|
{
|
||||||
|
const gchar *bundle_resource_dir = gtkosx_application_get_resource_path ();
|
||||||
|
|
||||||
|
gedit_locale_dir = g_build_filename (bundle_resource_dir,
|
||||||
|
"share",
|
||||||
|
"locale",
|
||||||
|
NULL);
|
||||||
|
gedit_lib_dir = g_build_filename (bundle_resource_dir,
|
||||||
|
"lib",
|
||||||
|
"gedit",
|
||||||
|
NULL);
|
||||||
|
gedit_plugins_data_dir = g_build_filename (bundle_resource_dir,
|
||||||
|
"share",
|
||||||
|
"gedit",
|
||||||
|
"plugins",
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
#endif /* OS_MACOS */
|
||||||
|
|
||||||
|
if (gedit_locale_dir == NULL)
|
||||||
|
{
|
||||||
|
gedit_locale_dir = g_strdup (GEDIT_CONFIG_LOCALE_DIR);
|
||||||
|
gedit_lib_dir = g_build_filename (LIBDIR,
|
||||||
|
"gedit",
|
||||||
|
NULL);
|
||||||
|
gedit_plugins_data_dir = g_build_filename (DATADIR,
|
||||||
|
"gedit",
|
||||||
|
"plugins",
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
user_config_dir = g_build_filename (g_get_user_config_dir (),
|
||||||
|
"gedit",
|
||||||
|
NULL);
|
||||||
|
user_data_dir = g_build_filename (g_get_user_data_dir (),
|
||||||
|
"gedit",
|
||||||
|
NULL);
|
||||||
|
user_plugins_dir = g_build_filename (user_data_dir,
|
||||||
|
"plugins",
|
||||||
|
NULL);
|
||||||
|
gedit_plugins_dir = g_build_filename (gedit_lib_dir,
|
||||||
|
"plugins",
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gedit_dirs_shutdown (void)
|
||||||
|
{
|
||||||
|
g_clear_pointer (&user_config_dir, g_free);
|
||||||
|
g_clear_pointer (&user_data_dir, g_free);
|
||||||
|
g_clear_pointer (&user_plugins_dir, g_free);
|
||||||
|
g_clear_pointer (&gedit_locale_dir, g_free);
|
||||||
|
g_clear_pointer (&gedit_lib_dir, g_free);
|
||||||
|
g_clear_pointer (&gedit_plugins_dir, g_free);
|
||||||
|
g_clear_pointer (&gedit_plugins_data_dir, g_free);
|
||||||
|
}
|
||||||
|
|
||||||
|
const gchar *
|
||||||
|
gedit_dirs_get_user_config_dir (void)
|
||||||
|
{
|
||||||
|
return user_config_dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
const gchar *
|
||||||
|
gedit_dirs_get_user_data_dir (void)
|
||||||
|
{
|
||||||
|
return user_data_dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
const gchar *
|
||||||
|
gedit_dirs_get_user_plugins_dir (void)
|
||||||
|
{
|
||||||
|
return user_plugins_dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
const gchar *
|
||||||
|
gedit_dirs_get_gedit_locale_dir (void)
|
||||||
|
{
|
||||||
|
return gedit_locale_dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
const gchar *
|
||||||
|
gedit_dirs_get_gedit_lib_dir (void)
|
||||||
|
{
|
||||||
|
return gedit_lib_dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
const gchar *
|
||||||
|
gedit_dirs_get_gedit_plugins_dir (void)
|
||||||
|
{
|
||||||
|
return gedit_plugins_dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
const gchar *
|
||||||
|
gedit_dirs_get_gedit_plugins_data_dir (void)
|
||||||
|
{
|
||||||
|
return gedit_plugins_data_dir;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ex:set ts=8 noet: */
|
52
gedit/gedit-dirs.h
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008 Ignacio Casal Quinteiro
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GEDIT_DIRS_H
|
||||||
|
#define GEDIT_DIRS_H
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
/* This function must be called before starting gedit. */
|
||||||
|
void gedit_dirs_init (void);
|
||||||
|
|
||||||
|
/* This function must be called before exiting gedit. */
|
||||||
|
void gedit_dirs_shutdown (void);
|
||||||
|
|
||||||
|
|
||||||
|
const gchar * gedit_dirs_get_user_config_dir (void);
|
||||||
|
|
||||||
|
const gchar * gedit_dirs_get_user_data_dir (void);
|
||||||
|
|
||||||
|
const gchar * gedit_dirs_get_user_plugins_dir (void);
|
||||||
|
|
||||||
|
const gchar * gedit_dirs_get_gedit_locale_dir (void);
|
||||||
|
|
||||||
|
const gchar * gedit_dirs_get_gedit_lib_dir (void);
|
||||||
|
|
||||||
|
const gchar * gedit_dirs_get_gedit_plugins_dir (void);
|
||||||
|
|
||||||
|
const gchar * gedit_dirs_get_gedit_plugins_data_dir (void);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* GEDIT_DIRS_H */
|
||||||
|
|
||||||
|
/* ex:set ts=8 noet: */
|
57
gedit/gedit-document-private.h
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
/*
|
||||||
|
* gedit-document.h
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
|
||||||
|
* Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi
|
||||||
|
* Copyright (C) 2002-2005 Paolo Maggi
|
||||||
|
* Copyright (C) 2014, 2020 Sébastien Wilmet
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GEDIT_DOCUMENT_PRIVATE_H
|
||||||
|
#define GEDIT_DOCUMENT_PRIVATE_H
|
||||||
|
|
||||||
|
#include "gedit-document.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define GEDIT_METADATA_ATTRIBUTE_POSITION "gedit-position"
|
||||||
|
#define GEDIT_METADATA_ATTRIBUTE_ENCODING "gedit-encoding"
|
||||||
|
#define GEDIT_METADATA_ATTRIBUTE_LANGUAGE "gedit-language"
|
||||||
|
|
||||||
|
G_GNUC_INTERNAL
|
||||||
|
glong _gedit_document_get_seconds_since_last_save_or_load (GeditDocument *doc);
|
||||||
|
|
||||||
|
G_GNUC_INTERNAL
|
||||||
|
gboolean _gedit_document_needs_saving (GeditDocument *doc);
|
||||||
|
|
||||||
|
G_GNUC_INTERNAL
|
||||||
|
gboolean _gedit_document_get_empty_search (GeditDocument *doc);
|
||||||
|
|
||||||
|
G_GNUC_INTERNAL
|
||||||
|
void _gedit_document_set_create (GeditDocument *doc,
|
||||||
|
gboolean create);
|
||||||
|
|
||||||
|
G_GNUC_INTERNAL
|
||||||
|
gboolean _gedit_document_get_create (GeditDocument *doc);
|
||||||
|
|
||||||
|
G_GNUC_INTERNAL
|
||||||
|
gboolean _gedit_document_is_untitled (GeditDocument *doc);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* GEDIT_DOCUMENT_PRIVATE_H */
|
||||||
|
/* ex:set ts=8 noet: */
|
1310
gedit/gedit-document.c
Normal file
79
gedit/gedit-document.h
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
/*
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
|
||||||
|
* Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi
|
||||||
|
* Copyright (C) 2002-2005 Paolo Maggi
|
||||||
|
* Copyright (C) 2014-2020 Sébastien Wilmet
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GEDIT_DOCUMENT_H
|
||||||
|
#define GEDIT_DOCUMENT_H
|
||||||
|
|
||||||
|
#include <tepl/tepl.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define GEDIT_TYPE_DOCUMENT (gedit_document_get_type())
|
||||||
|
|
||||||
|
G_DECLARE_DERIVABLE_TYPE (GeditDocument, gedit_document,
|
||||||
|
GEDIT, DOCUMENT,
|
||||||
|
TeplBuffer)
|
||||||
|
|
||||||
|
struct _GeditDocumentClass
|
||||||
|
{
|
||||||
|
TeplBufferClass parent_class;
|
||||||
|
|
||||||
|
/* Signals */
|
||||||
|
|
||||||
|
void (* load) (GeditDocument *document);
|
||||||
|
|
||||||
|
void (* loaded) (GeditDocument *document);
|
||||||
|
|
||||||
|
void (* save) (GeditDocument *document);
|
||||||
|
|
||||||
|
void (* saved) (GeditDocument *document);
|
||||||
|
};
|
||||||
|
|
||||||
|
GeditDocument * gedit_document_new (void);
|
||||||
|
|
||||||
|
GtkSourceFile * gedit_document_get_file (GeditDocument *doc);
|
||||||
|
|
||||||
|
gchar * gedit_document_get_content_type (GeditDocument *doc);
|
||||||
|
|
||||||
|
gchar * gedit_document_get_mime_type (GeditDocument *doc);
|
||||||
|
|
||||||
|
void gedit_document_set_language (GeditDocument *doc,
|
||||||
|
GtkSourceLanguage *lang);
|
||||||
|
|
||||||
|
gchar * gedit_document_get_metadata (GeditDocument *doc,
|
||||||
|
const gchar *key);
|
||||||
|
|
||||||
|
void gedit_document_set_metadata (GeditDocument *doc,
|
||||||
|
const gchar *first_key,
|
||||||
|
...);
|
||||||
|
|
||||||
|
void gedit_document_set_search_context (GeditDocument *doc,
|
||||||
|
GtkSourceSearchContext *search_context);
|
||||||
|
|
||||||
|
GtkSourceSearchContext *
|
||||||
|
gedit_document_get_search_context (GeditDocument *doc);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* GEDIT_DOCUMENT_H */
|
||||||
|
|
||||||
|
/* ex:set ts=8 noet: */
|
1728
gedit/gedit-documents-panel.c
Normal file
40
gedit/gedit-documents-panel.h
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
* gedit-documents-panel.h
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 2005 - Paolo Maggi
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GEDIT_DOCUMENTS_PANEL_H
|
||||||
|
#define GEDIT_DOCUMENTS_PANEL_H
|
||||||
|
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
#include <gedit/gedit-window.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define GEDIT_TYPE_DOCUMENTS_PANEL (gedit_documents_panel_get_type())
|
||||||
|
|
||||||
|
G_DECLARE_FINAL_TYPE (GeditDocumentsPanel, gedit_documents_panel, GEDIT, DOCUMENTS_PANEL, GtkBox)
|
||||||
|
|
||||||
|
GtkWidget *gedit_documents_panel_new (GeditWindow *window);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* GEDIT_DOCUMENTS_PANEL_H */
|
||||||
|
|
||||||
|
/* ex:set ts=8 noet: */
|
108
gedit/gedit-encoding-items.c
Normal file
|
@ -0,0 +1,108 @@
|
||||||
|
/*
|
||||||
|
* gedit-encoding-items.c
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 2014 - Jesse van den Kieboom
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "gedit-encoding-items.h"
|
||||||
|
|
||||||
|
#include <glib/gi18n.h>
|
||||||
|
|
||||||
|
#include "gedit-settings.h"
|
||||||
|
|
||||||
|
struct _GeditEncodingItem
|
||||||
|
{
|
||||||
|
const GtkSourceEncoding *encoding;
|
||||||
|
gchar *name;
|
||||||
|
};
|
||||||
|
|
||||||
|
static GeditEncodingItem *
|
||||||
|
gedit_encoding_item_new (const GtkSourceEncoding *encoding,
|
||||||
|
gchar *name)
|
||||||
|
{
|
||||||
|
GeditEncodingItem *item = g_slice_new (GeditEncodingItem);
|
||||||
|
|
||||||
|
item->encoding = encoding;
|
||||||
|
item->name = name;
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gedit_encoding_item_free (GeditEncodingItem *item)
|
||||||
|
{
|
||||||
|
if (item == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (item->name);
|
||||||
|
g_slice_free (GeditEncodingItem, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
const GtkSourceEncoding *
|
||||||
|
gedit_encoding_item_get_encoding (GeditEncodingItem *item)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (item != NULL, NULL);
|
||||||
|
|
||||||
|
return item->encoding;
|
||||||
|
}
|
||||||
|
|
||||||
|
const gchar *
|
||||||
|
gedit_encoding_item_get_name (GeditEncodingItem *item)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (item != NULL, NULL);
|
||||||
|
|
||||||
|
return item->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
GSList *
|
||||||
|
gedit_encoding_items_get (void)
|
||||||
|
{
|
||||||
|
const GtkSourceEncoding *current_encoding;
|
||||||
|
GSList *encodings;
|
||||||
|
GSList *items = NULL;
|
||||||
|
GSList *l;
|
||||||
|
|
||||||
|
encodings = gedit_settings_get_candidate_encodings (NULL);
|
||||||
|
|
||||||
|
current_encoding = gtk_source_encoding_get_current ();
|
||||||
|
|
||||||
|
for (l = encodings; l != NULL; l = l->next)
|
||||||
|
{
|
||||||
|
const GtkSourceEncoding *enc = l->data;
|
||||||
|
gchar *name;
|
||||||
|
|
||||||
|
if (enc == current_encoding)
|
||||||
|
{
|
||||||
|
name = g_strdup_printf (_("Current Locale (%s)"),
|
||||||
|
gtk_source_encoding_get_charset (enc));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
name = gtk_source_encoding_to_string (enc);
|
||||||
|
}
|
||||||
|
|
||||||
|
items = g_slist_prepend (items, gedit_encoding_item_new (enc, name));
|
||||||
|
}
|
||||||
|
|
||||||
|
g_slist_free (encodings);
|
||||||
|
|
||||||
|
return g_slist_reverse (items);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ex:set ts=8 noet: */
|
40
gedit/gedit-encoding-items.h
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
/*
|
||||||
|
* gedit-encoding-items.h
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 2014 - Jesse van den Kieboom
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GEDIT_ENCODING_ITEMS_H
|
||||||
|
#define GEDIT_ENCODING_ITEMS_H
|
||||||
|
|
||||||
|
#include <gtksourceview/gtksource.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
typedef struct _GeditEncodingItem GeditEncodingItem;
|
||||||
|
|
||||||
|
GSList *gedit_encoding_items_get (void);
|
||||||
|
|
||||||
|
void gedit_encoding_item_free (GeditEncodingItem *item);
|
||||||
|
const GtkSourceEncoding *gedit_encoding_item_get_encoding (GeditEncodingItem *item);
|
||||||
|
const gchar *gedit_encoding_item_get_name (GeditEncodingItem *item);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* GEDIT_ENCODING_ITEMS_H */
|
||||||
|
|
||||||
|
/* ex:set ts=8 noet: */
|
439
gedit/gedit-encodings-combo-box.c
Normal file
|
@ -0,0 +1,439 @@
|
||||||
|
/*
|
||||||
|
* gedit-encodings-combo-box.c
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 2003-2005 - Paolo Maggi
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "gedit-encodings-combo-box.h"
|
||||||
|
#include <glib/gi18n.h>
|
||||||
|
#include "gedit-encoding-items.h"
|
||||||
|
#include "gedit-encodings-dialog.h"
|
||||||
|
|
||||||
|
struct _GeditEncodingsComboBox
|
||||||
|
{
|
||||||
|
GtkComboBox parent_instance;
|
||||||
|
|
||||||
|
GtkListStore *store;
|
||||||
|
glong changed_id;
|
||||||
|
|
||||||
|
guint activated_item;
|
||||||
|
|
||||||
|
guint save_mode : 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
COLUMN_NAME,
|
||||||
|
COLUMN_ENCODING,
|
||||||
|
COLUMN_CONFIGURE_ROW, /* TRUE for the "Add or Remove..." row. */
|
||||||
|
N_COLUMNS
|
||||||
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
PROP_0,
|
||||||
|
PROP_SAVE_MODE,
|
||||||
|
LAST_PROP
|
||||||
|
};
|
||||||
|
|
||||||
|
static GParamSpec *properties[LAST_PROP];
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (GeditEncodingsComboBox, gedit_encodings_combo_box, GTK_TYPE_COMBO_BOX)
|
||||||
|
|
||||||
|
static void update_menu (GeditEncodingsComboBox *combo_box);
|
||||||
|
|
||||||
|
static void
|
||||||
|
gedit_encodings_combo_box_set_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
const GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
GeditEncodingsComboBox *combo;
|
||||||
|
|
||||||
|
combo = GEDIT_ENCODINGS_COMBO_BOX (object);
|
||||||
|
|
||||||
|
switch (prop_id)
|
||||||
|
{
|
||||||
|
case PROP_SAVE_MODE:
|
||||||
|
combo->save_mode = g_value_get_boolean (value);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gedit_encodings_combo_box_get_property (GObject *object,
|
||||||
|
guint prop_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
GeditEncodingsComboBox *combo;
|
||||||
|
|
||||||
|
combo = GEDIT_ENCODINGS_COMBO_BOX (object);
|
||||||
|
|
||||||
|
switch (prop_id)
|
||||||
|
{
|
||||||
|
case PROP_SAVE_MODE:
|
||||||
|
g_value_set_boolean (value, combo->save_mode);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gedit_encodings_combo_box_dispose (GObject *object)
|
||||||
|
{
|
||||||
|
GeditEncodingsComboBox *combo = GEDIT_ENCODINGS_COMBO_BOX (object);
|
||||||
|
|
||||||
|
g_clear_object (&combo->store);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (gedit_encodings_combo_box_parent_class)->dispose (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gedit_encodings_combo_box_constructed (GObject *object)
|
||||||
|
{
|
||||||
|
GeditEncodingsComboBox *combo = GEDIT_ENCODINGS_COMBO_BOX (object);
|
||||||
|
GtkCellRenderer *text_renderer;
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (gedit_encodings_combo_box_parent_class)->constructed (object);
|
||||||
|
|
||||||
|
/* Setup up the cells */
|
||||||
|
text_renderer = gtk_cell_renderer_text_new ();
|
||||||
|
gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (combo),
|
||||||
|
text_renderer, TRUE);
|
||||||
|
|
||||||
|
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo),
|
||||||
|
text_renderer,
|
||||||
|
"text",
|
||||||
|
COLUMN_NAME,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
update_menu (combo);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gedit_encodings_combo_box_class_init (GeditEncodingsComboBoxClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->set_property = gedit_encodings_combo_box_set_property;
|
||||||
|
object_class->get_property = gedit_encodings_combo_box_get_property;
|
||||||
|
object_class->dispose = gedit_encodings_combo_box_dispose;
|
||||||
|
object_class->constructed = gedit_encodings_combo_box_constructed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GeditEncodingsComboBox:save-mode:
|
||||||
|
*
|
||||||
|
* Whether the combo box should be used for saving a content. If
|
||||||
|
* %FALSE, the combo box is used for loading a content (e.g. a file)
|
||||||
|
* and the row "Automatically Detected" is added.
|
||||||
|
*/
|
||||||
|
/* TODO It'd be clearer if "save-mode" is renamed as "mode" with an
|
||||||
|
* enum: loading, saving. Or something like that.
|
||||||
|
*/
|
||||||
|
properties[PROP_SAVE_MODE] =
|
||||||
|
g_param_spec_boolean ("save-mode",
|
||||||
|
"Save Mode",
|
||||||
|
"Save Mode",
|
||||||
|
FALSE,
|
||||||
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
|
||||||
|
|
||||||
|
g_object_class_install_properties (object_class, LAST_PROP, properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
dialog_response_cb (GtkDialog *dialog,
|
||||||
|
gint response_id,
|
||||||
|
GeditEncodingsComboBox *menu)
|
||||||
|
{
|
||||||
|
update_menu (menu);
|
||||||
|
gtk_widget_destroy (GTK_WIDGET (dialog));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
configure_encodings (GeditEncodingsComboBox *menu)
|
||||||
|
{
|
||||||
|
GtkWidget *dialog;
|
||||||
|
|
||||||
|
GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (menu));
|
||||||
|
|
||||||
|
if (!gtk_widget_is_toplevel (toplevel))
|
||||||
|
{
|
||||||
|
toplevel = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_signal_handler_block (menu, menu->changed_id);
|
||||||
|
gtk_combo_box_set_active (GTK_COMBO_BOX (menu),
|
||||||
|
menu->activated_item);
|
||||||
|
g_signal_handler_unblock (menu, menu->changed_id);
|
||||||
|
|
||||||
|
dialog = gedit_encodings_dialog_new ();
|
||||||
|
|
||||||
|
if (toplevel != NULL)
|
||||||
|
{
|
||||||
|
GtkWindowGroup *wg;
|
||||||
|
|
||||||
|
gtk_window_set_transient_for (GTK_WINDOW (dialog),
|
||||||
|
GTK_WINDOW (toplevel));
|
||||||
|
|
||||||
|
if (gtk_window_has_group (GTK_WINDOW (toplevel)))
|
||||||
|
{
|
||||||
|
wg = gtk_window_get_group (GTK_WINDOW (toplevel));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wg = gtk_window_group_new ();
|
||||||
|
gtk_window_group_add_window (wg, GTK_WINDOW (toplevel));
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_window_group_add_window (wg, GTK_WINDOW (dialog));
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||||
|
|
||||||
|
g_signal_connect_after (dialog,
|
||||||
|
"response",
|
||||||
|
G_CALLBACK (dialog_response_cb),
|
||||||
|
menu);
|
||||||
|
|
||||||
|
gtk_widget_show (dialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
changed_cb (GeditEncodingsComboBox *menu,
|
||||||
|
GtkTreeModel *model)
|
||||||
|
{
|
||||||
|
GtkTreeIter iter;
|
||||||
|
gboolean configure = FALSE;
|
||||||
|
|
||||||
|
if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (menu), &iter))
|
||||||
|
{
|
||||||
|
gtk_tree_model_get (model, &iter,
|
||||||
|
COLUMN_CONFIGURE_ROW, &configure,
|
||||||
|
-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (configure)
|
||||||
|
{
|
||||||
|
configure_encodings (menu);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
menu->activated_item = gtk_combo_box_get_active (GTK_COMBO_BOX (menu));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
separator_func (GtkTreeModel *model,
|
||||||
|
GtkTreeIter *iter,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
gchar *str;
|
||||||
|
gboolean ret;
|
||||||
|
|
||||||
|
gtk_tree_model_get (model, iter, COLUMN_NAME, &str, -1);
|
||||||
|
ret = (str == NULL || str[0] == '\0');
|
||||||
|
g_free (str);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
add_separator (GtkListStore *store)
|
||||||
|
{
|
||||||
|
GtkTreeIter iter;
|
||||||
|
|
||||||
|
gtk_list_store_append (store, &iter);
|
||||||
|
gtk_list_store_set (store, &iter,
|
||||||
|
COLUMN_NAME, "",
|
||||||
|
COLUMN_ENCODING, NULL,
|
||||||
|
COLUMN_CONFIGURE_ROW, FALSE,
|
||||||
|
-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
update_menu (GeditEncodingsComboBox *menu)
|
||||||
|
{
|
||||||
|
GtkListStore *store;
|
||||||
|
GtkTreeIter iter;
|
||||||
|
GSList *encodings;
|
||||||
|
|
||||||
|
store = menu->store;
|
||||||
|
|
||||||
|
/* Unset the previous model */
|
||||||
|
g_signal_handler_block (menu, menu->changed_id);
|
||||||
|
gtk_list_store_clear (store);
|
||||||
|
gtk_combo_box_set_model (GTK_COMBO_BOX (menu), NULL);
|
||||||
|
|
||||||
|
if (!menu->save_mode)
|
||||||
|
{
|
||||||
|
gtk_list_store_append (store, &iter);
|
||||||
|
gtk_list_store_set (store, &iter,
|
||||||
|
COLUMN_NAME, _("Automatically Detected"),
|
||||||
|
COLUMN_ENCODING, NULL,
|
||||||
|
COLUMN_CONFIGURE_ROW, FALSE,
|
||||||
|
-1);
|
||||||
|
|
||||||
|
add_separator (store);
|
||||||
|
}
|
||||||
|
|
||||||
|
encodings = gedit_encoding_items_get ();
|
||||||
|
|
||||||
|
while (encodings)
|
||||||
|
{
|
||||||
|
GeditEncodingItem *item = encodings->data;
|
||||||
|
|
||||||
|
gtk_list_store_append (store, &iter);
|
||||||
|
gtk_list_store_set (store, &iter,
|
||||||
|
COLUMN_NAME, gedit_encoding_item_get_name (item),
|
||||||
|
COLUMN_ENCODING, gedit_encoding_item_get_encoding (item),
|
||||||
|
COLUMN_CONFIGURE_ROW, FALSE,
|
||||||
|
-1);
|
||||||
|
|
||||||
|
gedit_encoding_item_free (item);
|
||||||
|
encodings = g_slist_delete_link (encodings, encodings);
|
||||||
|
}
|
||||||
|
|
||||||
|
add_separator (store);
|
||||||
|
|
||||||
|
gtk_list_store_append (store, &iter);
|
||||||
|
gtk_list_store_set (store, &iter,
|
||||||
|
COLUMN_NAME, _("Add or Remove…"),
|
||||||
|
COLUMN_ENCODING, NULL,
|
||||||
|
COLUMN_CONFIGURE_ROW, TRUE,
|
||||||
|
-1);
|
||||||
|
|
||||||
|
/* set the model back */
|
||||||
|
gtk_combo_box_set_model (GTK_COMBO_BOX (menu),
|
||||||
|
GTK_TREE_MODEL (menu->store));
|
||||||
|
gtk_combo_box_set_active (GTK_COMBO_BOX (menu), 0);
|
||||||
|
|
||||||
|
g_signal_handler_unblock (menu, menu->changed_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gedit_encodings_combo_box_init (GeditEncodingsComboBox *menu)
|
||||||
|
{
|
||||||
|
menu->store = gtk_list_store_new (N_COLUMNS,
|
||||||
|
G_TYPE_STRING,
|
||||||
|
G_TYPE_POINTER,
|
||||||
|
G_TYPE_BOOLEAN);
|
||||||
|
|
||||||
|
gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (menu),
|
||||||
|
separator_func, NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
menu->changed_id = g_signal_connect (menu,
|
||||||
|
"changed",
|
||||||
|
G_CALLBACK (changed_cb),
|
||||||
|
menu->store);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gedit_encodings_combo_box_new:
|
||||||
|
* @save_mode: whether the combo box is used for saving a content.
|
||||||
|
*
|
||||||
|
* Creates a new encodings combo box object. If @save_mode is %FALSE, it means
|
||||||
|
* that the combo box is used for loading a content (e.g. a file), so the row
|
||||||
|
* "Automatically Detected" is added. For saving a content, the encoding must be
|
||||||
|
* provided.
|
||||||
|
*
|
||||||
|
* Returns: a new #GeditEncodingsComboBox object.
|
||||||
|
*/
|
||||||
|
GtkWidget *
|
||||||
|
gedit_encodings_combo_box_new (gboolean save_mode)
|
||||||
|
{
|
||||||
|
return g_object_new (GEDIT_TYPE_ENCODINGS_COMBO_BOX,
|
||||||
|
"save_mode", save_mode,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gedit_encodings_combo_box_get_selected_encoding:
|
||||||
|
* @menu: a #GeditEncodingsComboBox.
|
||||||
|
*
|
||||||
|
* Returns: the selected #GtkSourceEncoding, or %NULL if the encoding should be
|
||||||
|
* auto-detected (only for loading mode, not for saving).
|
||||||
|
*/
|
||||||
|
const GtkSourceEncoding *
|
||||||
|
gedit_encodings_combo_box_get_selected_encoding (GeditEncodingsComboBox *menu)
|
||||||
|
{
|
||||||
|
GtkTreeIter iter;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GEDIT_IS_ENCODINGS_COMBO_BOX (menu), NULL);
|
||||||
|
|
||||||
|
if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (menu), &iter))
|
||||||
|
{
|
||||||
|
const GtkSourceEncoding *ret;
|
||||||
|
GtkTreeModel *model;
|
||||||
|
|
||||||
|
model = gtk_combo_box_get_model (GTK_COMBO_BOX (menu));
|
||||||
|
|
||||||
|
gtk_tree_model_get (model, &iter,
|
||||||
|
COLUMN_ENCODING, &ret,
|
||||||
|
-1);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gedit_encodings_combo_box_set_selected_encoding:
|
||||||
|
* @menu: a #GeditEncodingsComboBox.
|
||||||
|
* @encoding: the #GtkSourceEncoding.
|
||||||
|
*
|
||||||
|
* Sets the selected encoding.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gedit_encodings_combo_box_set_selected_encoding (GeditEncodingsComboBox *menu,
|
||||||
|
const GtkSourceEncoding *encoding)
|
||||||
|
{
|
||||||
|
GtkTreeIter iter;
|
||||||
|
GtkTreeModel *model;
|
||||||
|
gboolean b;
|
||||||
|
|
||||||
|
g_return_if_fail (GEDIT_IS_ENCODINGS_COMBO_BOX (menu));
|
||||||
|
|
||||||
|
model = gtk_combo_box_get_model (GTK_COMBO_BOX (menu));
|
||||||
|
b = gtk_tree_model_get_iter_first (model, &iter);
|
||||||
|
|
||||||
|
while (b)
|
||||||
|
{
|
||||||
|
const GtkSourceEncoding *enc;
|
||||||
|
|
||||||
|
gtk_tree_model_get (model, &iter,
|
||||||
|
COLUMN_ENCODING, &enc,
|
||||||
|
-1);
|
||||||
|
|
||||||
|
if (enc == encoding)
|
||||||
|
{
|
||||||
|
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (menu), &iter);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
b = gtk_tree_model_iter_next (model, &iter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ex:set ts=8 noet: */
|
43
gedit/gedit-encodings-combo-box.h
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
/*
|
||||||
|
* gedit-encodings-combo-box.h
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 2003-2005 - Paolo Maggi
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GEDIT_ENCODINGS_COMBO_BOX_H
|
||||||
|
#define GEDIT_ENCODINGS_COMBO_BOX_H
|
||||||
|
|
||||||
|
#include <gtksourceview/gtksource.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define GEDIT_TYPE_ENCODINGS_COMBO_BOX (gedit_encodings_combo_box_get_type ())
|
||||||
|
|
||||||
|
G_DECLARE_FINAL_TYPE (GeditEncodingsComboBox, gedit_encodings_combo_box, GEDIT, ENCODINGS_COMBO_BOX, GtkComboBox)
|
||||||
|
|
||||||
|
GtkWidget *gedit_encodings_combo_box_new (gboolean save_mode);
|
||||||
|
|
||||||
|
const GtkSourceEncoding *gedit_encodings_combo_box_get_selected_encoding (GeditEncodingsComboBox *menu);
|
||||||
|
|
||||||
|
void gedit_encodings_combo_box_set_selected_encoding (GeditEncodingsComboBox *menu,
|
||||||
|
const GtkSourceEncoding *encoding);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* GEDIT_ENCODINGS_COMBO_BOX_H */
|
||||||
|
|
||||||
|
/* ex:set ts=8 noet: */
|
884
gedit/gedit-encodings-dialog.c
Normal file
|
@ -0,0 +1,884 @@
|
||||||
|
/*
|
||||||
|
* gedit-encodings-dialog.c
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 2002-2005 Paolo Maggi
|
||||||
|
* Copyright (C) 2015 Sébastien Wilmet
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "gedit-encodings-dialog.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <glib/gi18n.h>
|
||||||
|
#include <gtksourceview/gtksource.h>
|
||||||
|
|
||||||
|
#include "gedit-settings.h"
|
||||||
|
|
||||||
|
typedef enum _State
|
||||||
|
{
|
||||||
|
STATE_UNMODIFIED,
|
||||||
|
STATE_MODIFIED,
|
||||||
|
STATE_RESET
|
||||||
|
} State;
|
||||||
|
|
||||||
|
struct _GeditEncodingsDialog
|
||||||
|
{
|
||||||
|
GtkDialog parent_instance;
|
||||||
|
|
||||||
|
GSettings *enc_settings;
|
||||||
|
|
||||||
|
/* Available encodings */
|
||||||
|
GtkListStore *liststore_available;
|
||||||
|
GtkTreeModelSort *sort_available;
|
||||||
|
GtkTreeView *treeview_available;
|
||||||
|
GtkWidget *add_button;
|
||||||
|
|
||||||
|
/* Chosen encodings */
|
||||||
|
GtkListStore *liststore_chosen;
|
||||||
|
GtkTreeView *treeview_chosen;
|
||||||
|
GtkWidget *remove_button;
|
||||||
|
GtkWidget *up_button;
|
||||||
|
GtkWidget *down_button;
|
||||||
|
GtkWidget *reset_button;
|
||||||
|
|
||||||
|
State state;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
COLUMN_NAME,
|
||||||
|
COLUMN_CHARSET,
|
||||||
|
COLUMN_ENCODING,
|
||||||
|
N_COLUMNS
|
||||||
|
};
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (GeditEncodingsDialog, gedit_encodings_dialog, GTK_TYPE_DIALOG)
|
||||||
|
|
||||||
|
static void
|
||||||
|
set_modified (GeditEncodingsDialog *dialog)
|
||||||
|
{
|
||||||
|
dialog->state = STATE_MODIFIED;
|
||||||
|
gtk_widget_set_sensitive (dialog->reset_button, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
append_encoding (GtkListStore *liststore,
|
||||||
|
const GtkSourceEncoding *encoding)
|
||||||
|
{
|
||||||
|
GtkTreeIter iter;
|
||||||
|
|
||||||
|
gtk_list_store_append (liststore, &iter);
|
||||||
|
gtk_list_store_set (liststore, &iter,
|
||||||
|
COLUMN_NAME, gtk_source_encoding_get_name (encoding),
|
||||||
|
COLUMN_ENCODING, encoding,
|
||||||
|
-1);
|
||||||
|
|
||||||
|
if (encoding == gtk_source_encoding_get_current ())
|
||||||
|
{
|
||||||
|
gchar *charset = g_strdup_printf (_("%s (Current Locale)"),
|
||||||
|
gtk_source_encoding_get_charset (encoding));
|
||||||
|
|
||||||
|
gtk_list_store_set (liststore, &iter,
|
||||||
|
COLUMN_CHARSET, charset,
|
||||||
|
-1);
|
||||||
|
|
||||||
|
g_free (charset);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gtk_list_store_set (liststore, &iter,
|
||||||
|
COLUMN_CHARSET, gtk_source_encoding_get_charset (encoding),
|
||||||
|
-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
init_liststores (GeditEncodingsDialog *dialog,
|
||||||
|
gboolean reset)
|
||||||
|
{
|
||||||
|
gboolean default_candidates;
|
||||||
|
GSList *chosen_encodings;
|
||||||
|
GSList *all_encodings;
|
||||||
|
GSList *l;
|
||||||
|
|
||||||
|
/* Chosen encodings */
|
||||||
|
|
||||||
|
if (reset)
|
||||||
|
{
|
||||||
|
chosen_encodings = gtk_source_encoding_get_default_candidates ();
|
||||||
|
default_candidates = TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
chosen_encodings = gedit_settings_get_candidate_encodings (&default_candidates);
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_widget_set_sensitive (dialog->reset_button, !default_candidates);
|
||||||
|
|
||||||
|
for (l = chosen_encodings; l != NULL; l = l->next)
|
||||||
|
{
|
||||||
|
const GtkSourceEncoding *cur_encoding = l->data;
|
||||||
|
append_encoding (dialog->liststore_chosen, cur_encoding);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Available encodings */
|
||||||
|
|
||||||
|
all_encodings = gtk_source_encoding_get_all ();
|
||||||
|
|
||||||
|
for (l = chosen_encodings; l != NULL; l = l->next)
|
||||||
|
{
|
||||||
|
const GtkSourceEncoding *chosen_encoding = l->data;
|
||||||
|
all_encodings = g_slist_remove (all_encodings, chosen_encoding);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (l = all_encodings; l != NULL; l = l->next)
|
||||||
|
{
|
||||||
|
const GtkSourceEncoding *cur_encoding = l->data;
|
||||||
|
append_encoding (dialog->liststore_available, cur_encoding);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_slist_free (chosen_encodings);
|
||||||
|
g_slist_free (all_encodings);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
reset_dialog_response_cb (GtkDialog *msg_dialog,
|
||||||
|
gint response,
|
||||||
|
GeditEncodingsDialog *dialog)
|
||||||
|
{
|
||||||
|
if (response == GTK_RESPONSE_ACCEPT)
|
||||||
|
{
|
||||||
|
gtk_list_store_clear (dialog->liststore_available);
|
||||||
|
gtk_list_store_clear (dialog->liststore_chosen);
|
||||||
|
|
||||||
|
init_liststores (dialog, TRUE);
|
||||||
|
dialog->state = STATE_RESET;
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_widget_destroy (GTK_WIDGET (msg_dialog));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
reset_button_clicked_cb (GtkWidget *button,
|
||||||
|
GeditEncodingsDialog *dialog)
|
||||||
|
{
|
||||||
|
GtkDialog *msg_dialog;
|
||||||
|
|
||||||
|
msg_dialog = GTK_DIALOG (gtk_message_dialog_new (GTK_WINDOW (dialog),
|
||||||
|
GTK_DIALOG_DESTROY_WITH_PARENT |
|
||||||
|
GTK_DIALOG_MODAL,
|
||||||
|
GTK_MESSAGE_QUESTION,
|
||||||
|
GTK_BUTTONS_NONE,
|
||||||
|
"%s",
|
||||||
|
_("Do you really want to reset the "
|
||||||
|
"character encodings’ preferences?")));
|
||||||
|
|
||||||
|
gtk_dialog_add_buttons (msg_dialog,
|
||||||
|
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
||||||
|
_("_Reset"), GTK_RESPONSE_ACCEPT,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
g_signal_connect (msg_dialog,
|
||||||
|
"response",
|
||||||
|
G_CALLBACK (reset_dialog_response_cb),
|
||||||
|
dialog);
|
||||||
|
|
||||||
|
gtk_widget_show_all (GTK_WIDGET (msg_dialog));
|
||||||
|
}
|
||||||
|
|
||||||
|
static GSList *
|
||||||
|
get_chosen_encodings_list (GeditEncodingsDialog *dialog)
|
||||||
|
{
|
||||||
|
GtkTreeModel *model = GTK_TREE_MODEL (dialog->liststore_chosen);
|
||||||
|
GtkTreeIter iter;
|
||||||
|
gboolean iter_set;
|
||||||
|
GSList *ret = NULL;
|
||||||
|
|
||||||
|
iter_set = gtk_tree_model_get_iter_first (model, &iter);
|
||||||
|
|
||||||
|
while (iter_set)
|
||||||
|
{
|
||||||
|
const GtkSourceEncoding *encoding = NULL;
|
||||||
|
|
||||||
|
gtk_tree_model_get (model, &iter,
|
||||||
|
COLUMN_ENCODING, &encoding,
|
||||||
|
-1);
|
||||||
|
|
||||||
|
ret = g_slist_prepend (ret, (gpointer)encoding);
|
||||||
|
|
||||||
|
iter_set = gtk_tree_model_iter_next (model, &iter);
|
||||||
|
}
|
||||||
|
|
||||||
|
return g_slist_reverse (ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gchar **
|
||||||
|
encoding_list_to_strv (const GSList *enc_list)
|
||||||
|
{
|
||||||
|
GSList *l;
|
||||||
|
GPtrArray *array;
|
||||||
|
|
||||||
|
array = g_ptr_array_sized_new (g_slist_length ((GSList *)enc_list) + 1);
|
||||||
|
|
||||||
|
for (l = (GSList *)enc_list; l != NULL; l = l->next)
|
||||||
|
{
|
||||||
|
const GtkSourceEncoding *enc = l->data;
|
||||||
|
const gchar *charset = gtk_source_encoding_get_charset (enc);
|
||||||
|
|
||||||
|
g_return_val_if_fail (charset != NULL, NULL);
|
||||||
|
|
||||||
|
g_ptr_array_add (array, g_strdup (charset));
|
||||||
|
}
|
||||||
|
|
||||||
|
g_ptr_array_add (array, NULL);
|
||||||
|
|
||||||
|
return (gchar **)g_ptr_array_free (array, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
apply_settings (GeditEncodingsDialog *dialog)
|
||||||
|
{
|
||||||
|
switch (dialog->state)
|
||||||
|
{
|
||||||
|
case STATE_MODIFIED:
|
||||||
|
{
|
||||||
|
GSList *enc_list;
|
||||||
|
gchar **enc_strv;
|
||||||
|
|
||||||
|
enc_list = get_chosen_encodings_list (dialog);
|
||||||
|
enc_strv = encoding_list_to_strv (enc_list);
|
||||||
|
|
||||||
|
g_settings_set_strv (dialog->enc_settings,
|
||||||
|
GEDIT_SETTINGS_CANDIDATE_ENCODINGS,
|
||||||
|
(const gchar * const *)enc_strv);
|
||||||
|
|
||||||
|
g_slist_free (enc_list);
|
||||||
|
g_strfreev (enc_strv);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case STATE_RESET:
|
||||||
|
g_settings_reset (dialog->enc_settings,
|
||||||
|
GEDIT_SETTINGS_CANDIDATE_ENCODINGS);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case STATE_UNMODIFIED:
|
||||||
|
/* Do nothing. */
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
g_assert_not_reached ();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gedit_encodings_dialog_response (GtkDialog *gtk_dialog,
|
||||||
|
gint response_id)
|
||||||
|
{
|
||||||
|
GeditEncodingsDialog *dialog = GEDIT_ENCODINGS_DIALOG (gtk_dialog);
|
||||||
|
|
||||||
|
switch (response_id)
|
||||||
|
{
|
||||||
|
case GTK_RESPONSE_APPLY:
|
||||||
|
apply_settings (dialog);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GTK_RESPONSE_CANCEL:
|
||||||
|
default:
|
||||||
|
/* Do nothing */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gedit_encodings_dialog_dispose (GObject *object)
|
||||||
|
{
|
||||||
|
GeditEncodingsDialog *dialog = GEDIT_ENCODINGS_DIALOG (object);
|
||||||
|
|
||||||
|
g_clear_object (&dialog->enc_settings);
|
||||||
|
g_clear_object (&dialog->add_button);
|
||||||
|
g_clear_object (&dialog->remove_button);
|
||||||
|
g_clear_object (&dialog->up_button);
|
||||||
|
g_clear_object (&dialog->down_button);
|
||||||
|
g_clear_object (&dialog->reset_button);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (gedit_encodings_dialog_parent_class)->dispose (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gedit_encodings_dialog_class_init (GeditEncodingsDialogClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||||
|
GtkDialogClass *dialog_class = GTK_DIALOG_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->dispose = gedit_encodings_dialog_dispose;
|
||||||
|
|
||||||
|
dialog_class->response = gedit_encodings_dialog_response;
|
||||||
|
|
||||||
|
/* Bind class to template */
|
||||||
|
gtk_widget_class_set_template_from_resource (widget_class,
|
||||||
|
"/org/gnome/gedit/ui/gedit-encodings-dialog.ui");
|
||||||
|
gtk_widget_class_bind_template_child (widget_class, GeditEncodingsDialog, liststore_available);
|
||||||
|
gtk_widget_class_bind_template_child (widget_class, GeditEncodingsDialog, liststore_chosen);
|
||||||
|
gtk_widget_class_bind_template_child (widget_class, GeditEncodingsDialog, sort_available);
|
||||||
|
gtk_widget_class_bind_template_child (widget_class, GeditEncodingsDialog, treeview_available);
|
||||||
|
gtk_widget_class_bind_template_child (widget_class, GeditEncodingsDialog, treeview_chosen);
|
||||||
|
gtk_widget_class_bind_template_child_full (widget_class, "scrolledwindow_available", FALSE, 0);
|
||||||
|
gtk_widget_class_bind_template_child_full (widget_class, "scrolledwindow_chosen", FALSE, 0);
|
||||||
|
gtk_widget_class_bind_template_child_full (widget_class, "toolbar_available", FALSE, 0);
|
||||||
|
gtk_widget_class_bind_template_child_full (widget_class, "toolbar_chosen", FALSE, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
update_add_button_sensitivity (GeditEncodingsDialog *dialog)
|
||||||
|
{
|
||||||
|
GtkTreeSelection *selection;
|
||||||
|
gint count;
|
||||||
|
|
||||||
|
selection = gtk_tree_view_get_selection (dialog->treeview_available);
|
||||||
|
count = gtk_tree_selection_count_selected_rows (selection);
|
||||||
|
gtk_widget_set_sensitive (dialog->add_button, count > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
update_remove_button_sensitivity (GeditEncodingsDialog *dialog)
|
||||||
|
{
|
||||||
|
const GtkSourceEncoding *utf8_encoding;
|
||||||
|
const GtkSourceEncoding *current_encoding;
|
||||||
|
GtkTreeSelection *selection;
|
||||||
|
GtkTreeModel *model;
|
||||||
|
GList *selected_rows;
|
||||||
|
GList *l;
|
||||||
|
gboolean sensitive;
|
||||||
|
|
||||||
|
utf8_encoding = gtk_source_encoding_get_utf8 ();
|
||||||
|
current_encoding = gtk_source_encoding_get_current ();
|
||||||
|
|
||||||
|
selection = gtk_tree_view_get_selection (dialog->treeview_chosen);
|
||||||
|
|
||||||
|
selected_rows = gtk_tree_selection_get_selected_rows (selection, &model);
|
||||||
|
g_return_if_fail (model == GTK_TREE_MODEL (dialog->liststore_chosen));
|
||||||
|
|
||||||
|
sensitive = FALSE;
|
||||||
|
for (l = selected_rows; l != NULL; l = l->next)
|
||||||
|
{
|
||||||
|
GtkTreePath *path = l->data;
|
||||||
|
GtkTreeIter iter;
|
||||||
|
const GtkSourceEncoding *encoding = NULL;
|
||||||
|
|
||||||
|
if (!gtk_tree_model_get_iter (model, &iter, path))
|
||||||
|
{
|
||||||
|
g_warning ("Remove button: invalid path");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_tree_model_get (model, &iter,
|
||||||
|
COLUMN_ENCODING, &encoding,
|
||||||
|
-1);
|
||||||
|
|
||||||
|
/* If at least one encoding other than UTF-8 or current is
|
||||||
|
* selected, set the Remove button as sensitive. But if UTF-8 or
|
||||||
|
* current is selected, it won't be removed. So Ctrl+A works
|
||||||
|
* fine to remove (almost) all encodings in one go.
|
||||||
|
*/
|
||||||
|
if (encoding != utf8_encoding &&
|
||||||
|
encoding != current_encoding)
|
||||||
|
{
|
||||||
|
sensitive = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_widget_set_sensitive (dialog->remove_button, sensitive);
|
||||||
|
|
||||||
|
g_list_free_full (selected_rows, (GDestroyNotify) gtk_tree_path_free);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
update_up_down_buttons_sensitivity (GeditEncodingsDialog *dialog)
|
||||||
|
{
|
||||||
|
GtkTreeSelection *selection;
|
||||||
|
gint count;
|
||||||
|
GList *selected_rows;
|
||||||
|
GtkTreeModel *model;
|
||||||
|
GtkTreePath *path;
|
||||||
|
gint *indices;
|
||||||
|
gint depth;
|
||||||
|
gint items_count;
|
||||||
|
gboolean first_item_selected;
|
||||||
|
gboolean last_item_selected;
|
||||||
|
|
||||||
|
selection = gtk_tree_view_get_selection (dialog->treeview_chosen);
|
||||||
|
count = gtk_tree_selection_count_selected_rows (selection);
|
||||||
|
|
||||||
|
if (count != 1)
|
||||||
|
{
|
||||||
|
gtk_widget_set_sensitive (dialog->up_button, FALSE);
|
||||||
|
gtk_widget_set_sensitive (dialog->down_button, FALSE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
selected_rows = gtk_tree_selection_get_selected_rows (selection, &model);
|
||||||
|
g_assert (g_list_length (selected_rows) == 1);
|
||||||
|
|
||||||
|
path = selected_rows->data;
|
||||||
|
indices = gtk_tree_path_get_indices_with_depth (path, &depth);
|
||||||
|
g_assert (depth == 1);
|
||||||
|
|
||||||
|
items_count = gtk_tree_model_iter_n_children (model, NULL);
|
||||||
|
|
||||||
|
first_item_selected = indices[0] == 0;
|
||||||
|
last_item_selected = indices[0] == (items_count - 1);
|
||||||
|
|
||||||
|
gtk_widget_set_sensitive (dialog->up_button, !first_item_selected);
|
||||||
|
gtk_widget_set_sensitive (dialog->down_button, !last_item_selected);
|
||||||
|
|
||||||
|
g_list_free_full (selected_rows, (GDestroyNotify) gtk_tree_path_free);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
update_chosen_buttons_sensitivity (GeditEncodingsDialog *dialog)
|
||||||
|
{
|
||||||
|
update_remove_button_sensitivity (dialog);
|
||||||
|
update_up_down_buttons_sensitivity (dialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Removes all @paths from @orig, and append them at the end of @dest in the
|
||||||
|
* same order.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
transfer_encodings (GList *paths,
|
||||||
|
GtkListStore *orig,
|
||||||
|
GtkListStore *dest)
|
||||||
|
{
|
||||||
|
GtkTreeModel *model_orig = GTK_TREE_MODEL (orig);
|
||||||
|
GList *refs = NULL;
|
||||||
|
GList *l;
|
||||||
|
|
||||||
|
for (l = paths; l != NULL; l = l->next)
|
||||||
|
{
|
||||||
|
GtkTreePath *path = l->data;
|
||||||
|
refs = g_list_prepend (refs, gtk_tree_row_reference_new (model_orig, path));
|
||||||
|
}
|
||||||
|
|
||||||
|
refs = g_list_reverse (refs);
|
||||||
|
|
||||||
|
for (l = refs; l != NULL; l = l->next)
|
||||||
|
{
|
||||||
|
GtkTreeRowReference *ref = l->data;
|
||||||
|
GtkTreePath *path;
|
||||||
|
GtkTreeIter iter;
|
||||||
|
const GtkSourceEncoding *encoding = NULL;
|
||||||
|
|
||||||
|
path = gtk_tree_row_reference_get_path (ref);
|
||||||
|
|
||||||
|
if (!gtk_tree_model_get_iter (model_orig, &iter, path))
|
||||||
|
{
|
||||||
|
gtk_tree_path_free (path);
|
||||||
|
g_warning ("Remove encoding: invalid path");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Transfer encoding */
|
||||||
|
gtk_tree_model_get (model_orig, &iter,
|
||||||
|
COLUMN_ENCODING, &encoding,
|
||||||
|
-1);
|
||||||
|
|
||||||
|
append_encoding (dest, encoding);
|
||||||
|
|
||||||
|
gtk_list_store_remove (orig, &iter);
|
||||||
|
|
||||||
|
gtk_tree_path_free (path);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_list_free_full (refs, (GDestroyNotify) gtk_tree_row_reference_free);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
add_button_clicked_cb (GtkWidget *button,
|
||||||
|
GeditEncodingsDialog *dialog)
|
||||||
|
{
|
||||||
|
GtkTreeSelection *selection;
|
||||||
|
GtkTreeModel *model;
|
||||||
|
GList *filter_paths;
|
||||||
|
GList *children_paths = NULL;
|
||||||
|
GList *l;
|
||||||
|
|
||||||
|
selection = gtk_tree_view_get_selection (dialog->treeview_available);
|
||||||
|
filter_paths = gtk_tree_selection_get_selected_rows (selection, &model);
|
||||||
|
|
||||||
|
g_return_if_fail (model == GTK_TREE_MODEL (dialog->sort_available));
|
||||||
|
|
||||||
|
for (l = filter_paths; l != NULL; l = l->next)
|
||||||
|
{
|
||||||
|
GtkTreePath *filter_path = l->data;
|
||||||
|
GtkTreePath *child_path;
|
||||||
|
|
||||||
|
child_path = gtk_tree_model_sort_convert_path_to_child_path (dialog->sort_available,
|
||||||
|
filter_path);
|
||||||
|
|
||||||
|
children_paths = g_list_prepend (children_paths, child_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
children_paths = g_list_reverse (children_paths);
|
||||||
|
|
||||||
|
transfer_encodings (children_paths,
|
||||||
|
dialog->liststore_available,
|
||||||
|
dialog->liststore_chosen);
|
||||||
|
|
||||||
|
set_modified (dialog);
|
||||||
|
|
||||||
|
/* For the treeview_available, it's more natural to unselect the added
|
||||||
|
* encodings.
|
||||||
|
* Note that when removing encodings from treeview_chosen, it is
|
||||||
|
* desirable to keep a selection, so we can remove several elements in a
|
||||||
|
* row (if the user doesn't know that several elements can be selected
|
||||||
|
* at once with Ctrl or Shift).
|
||||||
|
*/
|
||||||
|
gtk_tree_selection_unselect_all (selection);
|
||||||
|
|
||||||
|
g_list_free_full (filter_paths, (GDestroyNotify) gtk_tree_path_free);
|
||||||
|
g_list_free_full (children_paths, (GDestroyNotify) gtk_tree_path_free);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
remove_button_clicked_cb (GtkWidget *button,
|
||||||
|
GeditEncodingsDialog *dialog)
|
||||||
|
{
|
||||||
|
const GtkSourceEncoding *utf8_encoding;
|
||||||
|
const GtkSourceEncoding *current_encoding;
|
||||||
|
GtkTreeSelection *selection;
|
||||||
|
GtkTreeModel *model;
|
||||||
|
GList *selected_rows;
|
||||||
|
GList *to_remove = NULL;
|
||||||
|
GList *l;
|
||||||
|
|
||||||
|
utf8_encoding = gtk_source_encoding_get_utf8 ();
|
||||||
|
current_encoding = gtk_source_encoding_get_current ();
|
||||||
|
|
||||||
|
selection = gtk_tree_view_get_selection (dialog->treeview_chosen);
|
||||||
|
selected_rows = gtk_tree_selection_get_selected_rows (selection, &model);
|
||||||
|
|
||||||
|
g_return_if_fail (model == GTK_TREE_MODEL (dialog->liststore_chosen));
|
||||||
|
|
||||||
|
/* Ensure that UTF-8 and the current locale encodings cannot be removed. */
|
||||||
|
for (l = selected_rows; l != NULL; l = l->next)
|
||||||
|
{
|
||||||
|
GtkTreePath *path = l->data;
|
||||||
|
GtkTreeIter iter;
|
||||||
|
const GtkSourceEncoding *encoding = NULL;
|
||||||
|
|
||||||
|
if (!gtk_tree_model_get_iter (model, &iter, path))
|
||||||
|
{
|
||||||
|
gtk_tree_path_free (path);
|
||||||
|
g_warning ("Remove button: invalid path");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_tree_model_get (model, &iter,
|
||||||
|
COLUMN_ENCODING, &encoding,
|
||||||
|
-1);
|
||||||
|
|
||||||
|
if (encoding == utf8_encoding ||
|
||||||
|
encoding == current_encoding)
|
||||||
|
{
|
||||||
|
gtk_tree_path_free (path);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
to_remove = g_list_prepend (to_remove, path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
to_remove = g_list_reverse (to_remove);
|
||||||
|
|
||||||
|
transfer_encodings (to_remove,
|
||||||
|
dialog->liststore_chosen,
|
||||||
|
dialog->liststore_available);
|
||||||
|
|
||||||
|
set_modified (dialog);
|
||||||
|
|
||||||
|
g_list_free (selected_rows);
|
||||||
|
g_list_free_full (to_remove, (GDestroyNotify) gtk_tree_path_free);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
up_button_clicked_cb (GtkWidget *button,
|
||||||
|
GeditEncodingsDialog *dialog)
|
||||||
|
{
|
||||||
|
GtkTreeSelection *selection;
|
||||||
|
GtkTreeModel *model;
|
||||||
|
GList *selected_rows;
|
||||||
|
GtkTreePath *path;
|
||||||
|
GtkTreeIter iter;
|
||||||
|
GtkTreeIter prev_iter;
|
||||||
|
|
||||||
|
selection = gtk_tree_view_get_selection (dialog->treeview_chosen);
|
||||||
|
selected_rows = gtk_tree_selection_get_selected_rows (selection, &model);
|
||||||
|
|
||||||
|
g_return_if_fail (model == GTK_TREE_MODEL (dialog->liststore_chosen));
|
||||||
|
g_return_if_fail (g_list_length (selected_rows) == 1);
|
||||||
|
|
||||||
|
path = selected_rows->data;
|
||||||
|
if (!gtk_tree_model_get_iter (model, &iter, path))
|
||||||
|
{
|
||||||
|
g_return_if_reached ();
|
||||||
|
}
|
||||||
|
|
||||||
|
prev_iter = iter;
|
||||||
|
if (!gtk_tree_model_iter_previous (model, &prev_iter))
|
||||||
|
{
|
||||||
|
g_return_if_reached ();
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_list_store_move_before (dialog->liststore_chosen,
|
||||||
|
&iter,
|
||||||
|
&prev_iter);
|
||||||
|
|
||||||
|
set_modified (dialog);
|
||||||
|
|
||||||
|
update_chosen_buttons_sensitivity (dialog);
|
||||||
|
|
||||||
|
g_list_free_full (selected_rows, (GDestroyNotify) gtk_tree_path_free);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
down_button_clicked_cb (GtkWidget *button,
|
||||||
|
GeditEncodingsDialog *dialog)
|
||||||
|
{
|
||||||
|
GtkTreeSelection *selection;
|
||||||
|
GtkTreeModel *model;
|
||||||
|
GList *selected_rows;
|
||||||
|
GtkTreePath *path;
|
||||||
|
GtkTreeIter iter;
|
||||||
|
GtkTreeIter next_iter;
|
||||||
|
|
||||||
|
selection = gtk_tree_view_get_selection (dialog->treeview_chosen);
|
||||||
|
selected_rows = gtk_tree_selection_get_selected_rows (selection, &model);
|
||||||
|
|
||||||
|
g_return_if_fail (model == GTK_TREE_MODEL (dialog->liststore_chosen));
|
||||||
|
g_return_if_fail (g_list_length (selected_rows) == 1);
|
||||||
|
|
||||||
|
path = selected_rows->data;
|
||||||
|
if (!gtk_tree_model_get_iter (model, &iter, path))
|
||||||
|
{
|
||||||
|
g_return_if_reached ();
|
||||||
|
}
|
||||||
|
|
||||||
|
next_iter = iter;
|
||||||
|
if (!gtk_tree_model_iter_next (model, &next_iter))
|
||||||
|
{
|
||||||
|
g_return_if_reached ();
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_list_store_move_after (dialog->liststore_chosen,
|
||||||
|
&iter,
|
||||||
|
&next_iter);
|
||||||
|
|
||||||
|
set_modified (dialog);
|
||||||
|
|
||||||
|
update_chosen_buttons_sensitivity (dialog);
|
||||||
|
|
||||||
|
g_list_free_full (selected_rows, (GDestroyNotify) gtk_tree_path_free);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
init_toolbar_available (GeditEncodingsDialog *dialog)
|
||||||
|
{
|
||||||
|
GtkWidget *scrolled_window;
|
||||||
|
GtkToolbar *toolbar;
|
||||||
|
GtkStyleContext *context;
|
||||||
|
|
||||||
|
scrolled_window = GTK_WIDGET (gtk_widget_get_template_child (GTK_WIDGET (dialog),
|
||||||
|
GEDIT_TYPE_ENCODINGS_DIALOG,
|
||||||
|
"scrolledwindow_available"));
|
||||||
|
|
||||||
|
toolbar = GTK_TOOLBAR (gtk_widget_get_template_child (GTK_WIDGET (dialog),
|
||||||
|
GEDIT_TYPE_ENCODINGS_DIALOG,
|
||||||
|
"toolbar_available"));
|
||||||
|
|
||||||
|
context = gtk_widget_get_style_context (scrolled_window);
|
||||||
|
gtk_style_context_set_junction_sides (context, GTK_JUNCTION_BOTTOM);
|
||||||
|
|
||||||
|
context = gtk_widget_get_style_context (GTK_WIDGET (toolbar));
|
||||||
|
gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP);
|
||||||
|
gtk_style_context_add_class (context, GTK_STYLE_CLASS_INLINE_TOOLBAR);
|
||||||
|
|
||||||
|
/* Add button */
|
||||||
|
dialog->add_button = GTK_WIDGET (gtk_tool_button_new (NULL, NULL));
|
||||||
|
g_object_ref_sink (dialog->add_button);
|
||||||
|
|
||||||
|
gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (dialog->add_button), "list-add-symbolic");
|
||||||
|
gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (dialog->add_button), _("Add"));
|
||||||
|
|
||||||
|
gtk_toolbar_insert (toolbar, GTK_TOOL_ITEM (dialog->add_button), -1);
|
||||||
|
|
||||||
|
g_signal_connect_object (dialog->add_button,
|
||||||
|
"clicked",
|
||||||
|
G_CALLBACK (add_button_clicked_cb),
|
||||||
|
dialog,
|
||||||
|
0);
|
||||||
|
|
||||||
|
gtk_widget_show_all (GTK_WIDGET (toolbar));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
init_toolbar_chosen (GeditEncodingsDialog *dialog)
|
||||||
|
{
|
||||||
|
GtkWidget *scrolled_window;
|
||||||
|
GtkToolbar *toolbar;
|
||||||
|
GtkStyleContext *context;
|
||||||
|
GtkWidget *left_box;
|
||||||
|
GtkWidget *right_box;
|
||||||
|
GtkToolItem *left_group;
|
||||||
|
GtkToolItem *right_group;
|
||||||
|
GtkToolItem *separator;
|
||||||
|
|
||||||
|
scrolled_window = GTK_WIDGET (gtk_widget_get_template_child (GTK_WIDGET (dialog),
|
||||||
|
GEDIT_TYPE_ENCODINGS_DIALOG,
|
||||||
|
"scrolledwindow_chosen"));
|
||||||
|
|
||||||
|
toolbar = GTK_TOOLBAR (gtk_widget_get_template_child (GTK_WIDGET (dialog),
|
||||||
|
GEDIT_TYPE_ENCODINGS_DIALOG,
|
||||||
|
"toolbar_chosen"));
|
||||||
|
|
||||||
|
context = gtk_widget_get_style_context (scrolled_window);
|
||||||
|
gtk_style_context_set_junction_sides (context, GTK_JUNCTION_BOTTOM);
|
||||||
|
|
||||||
|
context = gtk_widget_get_style_context (GTK_WIDGET (toolbar));
|
||||||
|
gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP);
|
||||||
|
gtk_style_context_add_class (context, GTK_STYLE_CLASS_INLINE_TOOLBAR);
|
||||||
|
|
||||||
|
/* Remove button */
|
||||||
|
dialog->remove_button = gtk_button_new_from_icon_name ("list-remove-symbolic", GTK_ICON_SIZE_SMALL_TOOLBAR);
|
||||||
|
g_object_ref_sink (dialog->remove_button);
|
||||||
|
gtk_widget_set_tooltip_text (dialog->remove_button, _("Remove"));
|
||||||
|
|
||||||
|
g_signal_connect_object (dialog->remove_button,
|
||||||
|
"clicked",
|
||||||
|
G_CALLBACK (remove_button_clicked_cb),
|
||||||
|
dialog,
|
||||||
|
0);
|
||||||
|
|
||||||
|
/* Up button */
|
||||||
|
dialog->up_button = gtk_button_new_from_icon_name ("go-up-symbolic", GTK_ICON_SIZE_SMALL_TOOLBAR);
|
||||||
|
g_object_ref_sink (dialog->up_button);
|
||||||
|
gtk_widget_set_tooltip_text (dialog->up_button, _("Move to a higher priority"));
|
||||||
|
|
||||||
|
g_signal_connect_object (dialog->up_button,
|
||||||
|
"clicked",
|
||||||
|
G_CALLBACK (up_button_clicked_cb),
|
||||||
|
dialog,
|
||||||
|
0);
|
||||||
|
|
||||||
|
/* Down button */
|
||||||
|
dialog->down_button = gtk_button_new_from_icon_name ("go-down-symbolic", GTK_ICON_SIZE_SMALL_TOOLBAR);
|
||||||
|
g_object_ref_sink (dialog->down_button);
|
||||||
|
gtk_widget_set_tooltip_text (dialog->down_button, _("Move to a lower priority"));
|
||||||
|
|
||||||
|
g_signal_connect_object (dialog->down_button,
|
||||||
|
"clicked",
|
||||||
|
G_CALLBACK (down_button_clicked_cb),
|
||||||
|
dialog,
|
||||||
|
0);
|
||||||
|
|
||||||
|
/* Left group (with a trick for rounded borders) */
|
||||||
|
left_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||||
|
left_group = gtk_tool_item_new ();
|
||||||
|
gtk_box_pack_start (GTK_BOX (left_box), dialog->remove_button, FALSE, FALSE, 0);
|
||||||
|
gtk_box_pack_start (GTK_BOX (left_box), dialog->up_button, FALSE, FALSE, 0);
|
||||||
|
gtk_box_pack_start (GTK_BOX (left_box), dialog->down_button, FALSE, FALSE, 0);
|
||||||
|
gtk_container_add (GTK_CONTAINER (left_group), left_box);
|
||||||
|
gtk_toolbar_insert (toolbar, left_group, -1);
|
||||||
|
|
||||||
|
/* Separator */
|
||||||
|
separator = gtk_separator_tool_item_new ();
|
||||||
|
gtk_separator_tool_item_set_draw (GTK_SEPARATOR_TOOL_ITEM (separator), FALSE);
|
||||||
|
gtk_tool_item_set_expand (separator, TRUE);
|
||||||
|
gtk_toolbar_insert (toolbar, separator, -1);
|
||||||
|
|
||||||
|
/* Reset button */
|
||||||
|
dialog->reset_button = gtk_button_new_with_mnemonic (_("_Reset"));
|
||||||
|
g_object_ref_sink (dialog->reset_button);
|
||||||
|
|
||||||
|
g_signal_connect_object (dialog->reset_button,
|
||||||
|
"clicked",
|
||||||
|
G_CALLBACK (reset_button_clicked_cb),
|
||||||
|
dialog,
|
||||||
|
0);
|
||||||
|
|
||||||
|
/* Right group */
|
||||||
|
right_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||||
|
right_group = gtk_tool_item_new ();
|
||||||
|
gtk_box_pack_start (GTK_BOX (right_box), dialog->reset_button, FALSE, FALSE, 0);
|
||||||
|
gtk_container_add (GTK_CONTAINER (right_group), right_box);
|
||||||
|
gtk_toolbar_insert (toolbar, right_group, -1);
|
||||||
|
|
||||||
|
gtk_widget_show_all (GTK_WIDGET (toolbar));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gedit_encodings_dialog_init (GeditEncodingsDialog *dialog)
|
||||||
|
{
|
||||||
|
GtkTreeSelection *selection;
|
||||||
|
|
||||||
|
dialog->enc_settings = g_settings_new ("org.gnome.gedit.preferences.encodings");
|
||||||
|
|
||||||
|
gtk_widget_init_template (GTK_WIDGET (dialog));
|
||||||
|
|
||||||
|
init_toolbar_available (dialog);
|
||||||
|
init_toolbar_chosen (dialog);
|
||||||
|
init_liststores (dialog, FALSE);
|
||||||
|
dialog->state = STATE_UNMODIFIED;
|
||||||
|
|
||||||
|
/* Available encodings */
|
||||||
|
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (dialog->sort_available),
|
||||||
|
COLUMN_NAME,
|
||||||
|
GTK_SORT_ASCENDING);
|
||||||
|
|
||||||
|
selection = gtk_tree_view_get_selection (dialog->treeview_available);
|
||||||
|
|
||||||
|
g_signal_connect_swapped (selection,
|
||||||
|
"changed",
|
||||||
|
G_CALLBACK (update_add_button_sensitivity),
|
||||||
|
dialog);
|
||||||
|
|
||||||
|
update_add_button_sensitivity (dialog);
|
||||||
|
|
||||||
|
/* Chosen encodings */
|
||||||
|
selection = gtk_tree_view_get_selection (dialog->treeview_chosen);
|
||||||
|
|
||||||
|
g_signal_connect_swapped (selection,
|
||||||
|
"changed",
|
||||||
|
G_CALLBACK (update_chosen_buttons_sensitivity),
|
||||||
|
dialog);
|
||||||
|
|
||||||
|
update_chosen_buttons_sensitivity (dialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkWidget *
|
||||||
|
gedit_encodings_dialog_new (void)
|
||||||
|
{
|
||||||
|
return g_object_new (GEDIT_TYPE_ENCODINGS_DIALOG,
|
||||||
|
"use-header-bar", TRUE,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ex:set ts=8 noet: */
|
37
gedit/gedit-encodings-dialog.h
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
/*
|
||||||
|
* gedit-encodings-dialog.h
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 2003-2005 Paolo Maggi
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GEDIT_ENCODINGS_DIALOG_H
|
||||||
|
#define GEDIT_ENCODINGS_DIALOG_H
|
||||||
|
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define GEDIT_TYPE_ENCODINGS_DIALOG (gedit_encodings_dialog_get_type())
|
||||||
|
|
||||||
|
G_DECLARE_FINAL_TYPE (GeditEncodingsDialog, gedit_encodings_dialog, GEDIT, ENCODINGS_DIALOG, GtkDialog)
|
||||||
|
|
||||||
|
GtkWidget *gedit_encodings_dialog_new (void);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* GEDIT_ENCODINGS_DIALOG_H */
|
||||||
|
/* ex:set ts=8 noet: */
|
51
gedit/gedit-factory.c
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020 Sébastien Wilmet <swilmet@gnome.org>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "gedit-factory.h"
|
||||||
|
#include <glib/gi18n.h>
|
||||||
|
#include "gedit-dirs.h"
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (GeditFactory, gedit_factory, TEPL_TYPE_ABSTRACT_FACTORY)
|
||||||
|
|
||||||
|
static GFile *
|
||||||
|
gedit_factory_create_metadata_manager_file (TeplAbstractFactory *factory)
|
||||||
|
{
|
||||||
|
return g_file_new_build_filename (gedit_dirs_get_user_data_dir (),
|
||||||
|
"gedit-metadata.xml",
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gedit_factory_class_init (GeditFactoryClass *klass)
|
||||||
|
{
|
||||||
|
TeplAbstractFactoryClass *factory_class = TEPL_ABSTRACT_FACTORY_CLASS (klass);
|
||||||
|
|
||||||
|
factory_class->create_metadata_manager_file = gedit_factory_create_metadata_manager_file;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gedit_factory_init (GeditFactory *factory)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
GeditFactory *
|
||||||
|
gedit_factory_new (void)
|
||||||
|
{
|
||||||
|
return g_object_new (GEDIT_TYPE_FACTORY, NULL);
|
||||||
|
}
|
53
gedit/gedit-factory.h
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
/*
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020 Sébastien Wilmet <swilmet@gnome.org>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GEDIT_FACTORY_H
|
||||||
|
#define GEDIT_FACTORY_H
|
||||||
|
|
||||||
|
#include <tepl/tepl.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define GEDIT_TYPE_FACTORY (gedit_factory_get_type ())
|
||||||
|
#define GEDIT_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_FACTORY, GeditFactory))
|
||||||
|
#define GEDIT_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEDIT_TYPE_FACTORY, GeditFactoryClass))
|
||||||
|
#define GEDIT_IS_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEDIT_TYPE_FACTORY))
|
||||||
|
#define GEDIT_IS_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_FACTORY))
|
||||||
|
#define GEDIT_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEDIT_TYPE_FACTORY, GeditFactoryClass))
|
||||||
|
|
||||||
|
typedef struct _GeditFactory GeditFactory;
|
||||||
|
typedef struct _GeditFactoryClass GeditFactoryClass;
|
||||||
|
|
||||||
|
struct _GeditFactory
|
||||||
|
{
|
||||||
|
TeplAbstractFactory parent;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GeditFactoryClass
|
||||||
|
{
|
||||||
|
TeplAbstractFactoryClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
GType gedit_factory_get_type (void);
|
||||||
|
|
||||||
|
GeditFactory * gedit_factory_new (void);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* GEDIT_FACTORY_H */
|
465
gedit/gedit-file-chooser-dialog-gtk.c
Normal file
|
@ -0,0 +1,465 @@
|
||||||
|
/*
|
||||||
|
* gedit-file-chooser-dialog-gtk.c
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 2005-2007 - Paolo Maggi
|
||||||
|
* Copyright (C) 2014 - Jesse van den Kieboom
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* TODO: Override set_extra_widget */
|
||||||
|
/* TODO: add encoding property */
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "gedit-file-chooser-dialog-gtk.h"
|
||||||
|
#include <string.h>
|
||||||
|
#include <glib/gi18n.h>
|
||||||
|
#include "gedit-encodings-combo-box.h"
|
||||||
|
#include "gedit-debug.h"
|
||||||
|
#include "gedit-enum-types.h"
|
||||||
|
#include "gedit-settings.h"
|
||||||
|
#include "gedit-utils.h"
|
||||||
|
#include "gedit-file-chooser.h"
|
||||||
|
|
||||||
|
struct _GeditFileChooserDialogGtk
|
||||||
|
{
|
||||||
|
GtkFileChooserDialog parent_instance;
|
||||||
|
|
||||||
|
GeditFileChooser *gedit_file_chooser;
|
||||||
|
|
||||||
|
GtkWidget *option_menu;
|
||||||
|
GtkWidget *extra_widget;
|
||||||
|
|
||||||
|
GtkWidget *newline_label;
|
||||||
|
GtkWidget *newline_combo;
|
||||||
|
GtkListStore *newline_store;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void gedit_file_chooser_dialog_gtk_chooser_init (gpointer g_iface, gpointer iface_data);
|
||||||
|
|
||||||
|
G_DEFINE_TYPE_EXTENDED (GeditFileChooserDialogGtk,
|
||||||
|
gedit_file_chooser_dialog_gtk,
|
||||||
|
GTK_TYPE_FILE_CHOOSER_DIALOG,
|
||||||
|
0,
|
||||||
|
G_IMPLEMENT_INTERFACE (GEDIT_TYPE_FILE_CHOOSER_DIALOG,
|
||||||
|
gedit_file_chooser_dialog_gtk_chooser_init))
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
chooser_set_encoding (GeditFileChooserDialog *dialog,
|
||||||
|
const GtkSourceEncoding *encoding)
|
||||||
|
{
|
||||||
|
GeditFileChooserDialogGtk *dialog_gtk = GEDIT_FILE_CHOOSER_DIALOG_GTK (dialog);
|
||||||
|
|
||||||
|
g_return_if_fail (GEDIT_IS_ENCODINGS_COMBO_BOX (dialog_gtk->option_menu));
|
||||||
|
|
||||||
|
gedit_encodings_combo_box_set_selected_encoding (GEDIT_ENCODINGS_COMBO_BOX (dialog_gtk->option_menu),
|
||||||
|
encoding);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const GtkSourceEncoding *
|
||||||
|
chooser_get_encoding (GeditFileChooserDialog *dialog)
|
||||||
|
{
|
||||||
|
GeditFileChooserDialogGtk *dialog_gtk = GEDIT_FILE_CHOOSER_DIALOG_GTK (dialog);
|
||||||
|
|
||||||
|
g_return_val_if_fail (GEDIT_IS_ENCODINGS_COMBO_BOX (dialog_gtk->option_menu), NULL);
|
||||||
|
g_return_val_if_fail ((gtk_file_chooser_get_action (GTK_FILE_CHOOSER (dialog)) == GTK_FILE_CHOOSER_ACTION_OPEN ||
|
||||||
|
gtk_file_chooser_get_action (GTK_FILE_CHOOSER (dialog)) == GTK_FILE_CHOOSER_ACTION_SAVE), NULL);
|
||||||
|
|
||||||
|
return gedit_encodings_combo_box_get_selected_encoding (
|
||||||
|
GEDIT_ENCODINGS_COMBO_BOX (dialog_gtk->option_menu));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
set_enum_combo (GtkComboBox *combo,
|
||||||
|
gint value)
|
||||||
|
{
|
||||||
|
GtkTreeIter iter;
|
||||||
|
GtkTreeModel *model;
|
||||||
|
|
||||||
|
model = gtk_combo_box_get_model (combo);
|
||||||
|
|
||||||
|
if (!gtk_tree_model_get_iter_first (model, &iter))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
gint nt;
|
||||||
|
|
||||||
|
gtk_tree_model_get (model, &iter, 1, &nt, -1);
|
||||||
|
|
||||||
|
if (value == nt)
|
||||||
|
{
|
||||||
|
gtk_combo_box_set_active_iter (combo, &iter);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} while (gtk_tree_model_iter_next (model, &iter));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
chooser_set_newline_type (GeditFileChooserDialog *dialog,
|
||||||
|
GtkSourceNewlineType newline_type)
|
||||||
|
{
|
||||||
|
GeditFileChooserDialogGtk *dialog_gtk = GEDIT_FILE_CHOOSER_DIALOG_GTK (dialog);
|
||||||
|
|
||||||
|
g_return_if_fail (gtk_file_chooser_get_action (GTK_FILE_CHOOSER (dialog)) == GTK_FILE_CHOOSER_ACTION_SAVE);
|
||||||
|
|
||||||
|
set_enum_combo (GTK_COMBO_BOX (dialog_gtk->newline_combo), newline_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
static GtkSourceNewlineType
|
||||||
|
chooser_get_newline_type (GeditFileChooserDialog *dialog)
|
||||||
|
{
|
||||||
|
GeditFileChooserDialogGtk *dialog_gtk = GEDIT_FILE_CHOOSER_DIALOG_GTK (dialog);
|
||||||
|
GtkTreeIter iter;
|
||||||
|
GtkSourceNewlineType newline_type;
|
||||||
|
|
||||||
|
g_return_val_if_fail (gtk_file_chooser_get_action (GTK_FILE_CHOOSER (dialog)) == GTK_FILE_CHOOSER_ACTION_SAVE,
|
||||||
|
GTK_SOURCE_NEWLINE_TYPE_DEFAULT);
|
||||||
|
|
||||||
|
gtk_combo_box_get_active_iter (GTK_COMBO_BOX (dialog_gtk->newline_combo),
|
||||||
|
&iter);
|
||||||
|
|
||||||
|
gtk_tree_model_get (GTK_TREE_MODEL (dialog_gtk->newline_store),
|
||||||
|
&iter,
|
||||||
|
1,
|
||||||
|
&newline_type,
|
||||||
|
-1);
|
||||||
|
|
||||||
|
return newline_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
chooser_set_current_folder (GeditFileChooserDialog *dialog,
|
||||||
|
GFile *folder)
|
||||||
|
{
|
||||||
|
gchar *uri = NULL;
|
||||||
|
|
||||||
|
if (folder != NULL)
|
||||||
|
{
|
||||||
|
uri = g_file_get_uri (folder);
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (dialog), uri);
|
||||||
|
g_free (uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
chooser_set_current_name (GeditFileChooserDialog *dialog,
|
||||||
|
const gchar *name)
|
||||||
|
{
|
||||||
|
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), name);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
chooser_set_file (GeditFileChooserDialog *dialog,
|
||||||
|
GFile *file)
|
||||||
|
{
|
||||||
|
gtk_file_chooser_set_file (GTK_FILE_CHOOSER (dialog), file, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static GFile *
|
||||||
|
chooser_get_file (GeditFileChooserDialog *dialog)
|
||||||
|
{
|
||||||
|
return gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
chooser_set_do_overwrite_confirmation (GeditFileChooserDialog *dialog,
|
||||||
|
gboolean overwrite_confirmation)
|
||||||
|
{
|
||||||
|
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), overwrite_confirmation);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
chooser_show (GeditFileChooserDialog *dialog)
|
||||||
|
{
|
||||||
|
gtk_window_present (GTK_WINDOW (dialog));
|
||||||
|
gtk_widget_grab_focus (GTK_WIDGET (dialog));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
chooser_destroy (GeditFileChooserDialog *dialog)
|
||||||
|
{
|
||||||
|
gtk_widget_destroy (GTK_WIDGET (dialog));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
chooser_set_modal (GeditFileChooserDialog *dialog,
|
||||||
|
gboolean is_modal)
|
||||||
|
{
|
||||||
|
gtk_window_set_modal (GTK_WINDOW (dialog), is_modal);
|
||||||
|
}
|
||||||
|
|
||||||
|
static GtkWindow *
|
||||||
|
chooser_get_window (GeditFileChooserDialog *dialog)
|
||||||
|
{
|
||||||
|
return GTK_WINDOW (dialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gedit_file_chooser_dialog_gtk_chooser_init (gpointer g_iface,
|
||||||
|
gpointer iface_data)
|
||||||
|
{
|
||||||
|
GeditFileChooserDialogInterface *iface = g_iface;
|
||||||
|
|
||||||
|
iface->set_encoding = chooser_set_encoding;
|
||||||
|
iface->get_encoding = chooser_get_encoding;
|
||||||
|
|
||||||
|
iface->set_newline_type = chooser_set_newline_type;
|
||||||
|
iface->get_newline_type = chooser_get_newline_type;
|
||||||
|
|
||||||
|
iface->set_current_folder = chooser_set_current_folder;
|
||||||
|
iface->set_current_name = chooser_set_current_name;
|
||||||
|
iface->set_file = chooser_set_file;
|
||||||
|
iface->get_file = chooser_get_file;
|
||||||
|
iface->set_do_overwrite_confirmation = chooser_set_do_overwrite_confirmation;
|
||||||
|
iface->show = chooser_show;
|
||||||
|
iface->destroy = chooser_destroy;
|
||||||
|
iface->set_modal = chooser_set_modal;
|
||||||
|
iface->get_window = chooser_get_window;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gedit_file_chooser_dialog_gtk_dispose (GObject *object)
|
||||||
|
{
|
||||||
|
GeditFileChooserDialogGtk *dialog = GEDIT_FILE_CHOOSER_DIALOG_GTK (object);
|
||||||
|
|
||||||
|
g_clear_object (&dialog->gedit_file_chooser);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (gedit_file_chooser_dialog_gtk_parent_class)->dispose (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gedit_file_chooser_dialog_gtk_class_init (GeditFileChooserDialogGtkClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->dispose = gedit_file_chooser_dialog_gtk_dispose;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
create_option_menu (GeditFileChooserDialogGtk *dialog)
|
||||||
|
{
|
||||||
|
GtkWidget *label;
|
||||||
|
GtkWidget *menu;
|
||||||
|
gboolean save_mode;
|
||||||
|
|
||||||
|
label = gtk_label_new_with_mnemonic (_("C_haracter Encoding:"));
|
||||||
|
gtk_widget_set_halign (label, GTK_ALIGN_START);
|
||||||
|
|
||||||
|
save_mode = TRUE;
|
||||||
|
menu = gedit_encodings_combo_box_new (save_mode);
|
||||||
|
|
||||||
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), menu);
|
||||||
|
|
||||||
|
gtk_box_pack_start (GTK_BOX (dialog->extra_widget),
|
||||||
|
label,
|
||||||
|
FALSE,
|
||||||
|
TRUE,
|
||||||
|
0);
|
||||||
|
|
||||||
|
gtk_box_pack_start (GTK_BOX (dialog->extra_widget),
|
||||||
|
menu,
|
||||||
|
TRUE,
|
||||||
|
TRUE,
|
||||||
|
0);
|
||||||
|
|
||||||
|
gtk_widget_show (label);
|
||||||
|
gtk_widget_show (menu);
|
||||||
|
|
||||||
|
dialog->option_menu = menu;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
update_newline_visibility (GeditFileChooserDialogGtk *dialog)
|
||||||
|
{
|
||||||
|
gboolean visible = gtk_file_chooser_get_action (GTK_FILE_CHOOSER (dialog)) == GTK_FILE_CHOOSER_ACTION_SAVE;
|
||||||
|
|
||||||
|
gtk_widget_set_visible (dialog->newline_label, visible);
|
||||||
|
gtk_widget_set_visible (dialog->newline_combo, visible);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
newline_combo_append (GtkComboBox *combo,
|
||||||
|
GtkListStore *store,
|
||||||
|
GtkTreeIter *iter,
|
||||||
|
const gchar *label,
|
||||||
|
GtkSourceNewlineType newline_type)
|
||||||
|
{
|
||||||
|
gtk_list_store_append (store, iter);
|
||||||
|
gtk_list_store_set (store, iter, 0, label, 1, newline_type, -1);
|
||||||
|
|
||||||
|
if (newline_type == GTK_SOURCE_NEWLINE_TYPE_DEFAULT)
|
||||||
|
{
|
||||||
|
gtk_combo_box_set_active_iter (combo, iter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
create_newline_combo (GeditFileChooserDialogGtk *dialog)
|
||||||
|
{
|
||||||
|
GtkWidget *label, *combo;
|
||||||
|
GtkListStore *store;
|
||||||
|
GtkCellRenderer *renderer;
|
||||||
|
GtkTreeIter iter;
|
||||||
|
|
||||||
|
label = gtk_label_new_with_mnemonic (_("L_ine Ending:"));
|
||||||
|
gtk_widget_set_halign (label, GTK_ALIGN_START);
|
||||||
|
|
||||||
|
store = gtk_list_store_new (2, G_TYPE_STRING, GTK_SOURCE_TYPE_NEWLINE_TYPE);
|
||||||
|
combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store));
|
||||||
|
renderer = gtk_cell_renderer_text_new ();
|
||||||
|
|
||||||
|
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo),
|
||||||
|
renderer,
|
||||||
|
TRUE);
|
||||||
|
|
||||||
|
gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo),
|
||||||
|
renderer,
|
||||||
|
"text",
|
||||||
|
0);
|
||||||
|
|
||||||
|
newline_combo_append (GTK_COMBO_BOX (combo),
|
||||||
|
store,
|
||||||
|
&iter,
|
||||||
|
gedit_utils_newline_type_to_string (GTK_SOURCE_NEWLINE_TYPE_LF),
|
||||||
|
GTK_SOURCE_NEWLINE_TYPE_LF);
|
||||||
|
|
||||||
|
newline_combo_append (GTK_COMBO_BOX (combo),
|
||||||
|
store,
|
||||||
|
&iter,
|
||||||
|
gedit_utils_newline_type_to_string (GTK_SOURCE_NEWLINE_TYPE_CR),
|
||||||
|
GTK_SOURCE_NEWLINE_TYPE_CR);
|
||||||
|
|
||||||
|
newline_combo_append (GTK_COMBO_BOX (combo),
|
||||||
|
store,
|
||||||
|
&iter,
|
||||||
|
gedit_utils_newline_type_to_string (GTK_SOURCE_NEWLINE_TYPE_CR_LF),
|
||||||
|
GTK_SOURCE_NEWLINE_TYPE_CR_LF);
|
||||||
|
|
||||||
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
|
||||||
|
|
||||||
|
gtk_box_pack_start (GTK_BOX (dialog->extra_widget),
|
||||||
|
label,
|
||||||
|
FALSE,
|
||||||
|
TRUE,
|
||||||
|
0);
|
||||||
|
|
||||||
|
gtk_box_pack_start (GTK_BOX (dialog->extra_widget),
|
||||||
|
combo,
|
||||||
|
TRUE,
|
||||||
|
TRUE,
|
||||||
|
0);
|
||||||
|
|
||||||
|
dialog->newline_combo = combo;
|
||||||
|
dialog->newline_label = label;
|
||||||
|
dialog->newline_store = store;
|
||||||
|
|
||||||
|
update_newline_visibility (dialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
create_extra_widget (GeditFileChooserDialogGtk *dialog)
|
||||||
|
{
|
||||||
|
dialog->extra_widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
||||||
|
gtk_widget_show (dialog->extra_widget);
|
||||||
|
|
||||||
|
create_option_menu (dialog);
|
||||||
|
create_newline_combo (dialog);
|
||||||
|
|
||||||
|
gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (dialog), dialog->extra_widget);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
action_changed (GeditFileChooserDialogGtk *dialog,
|
||||||
|
GParamSpec *pspec,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
GtkFileChooserAction action;
|
||||||
|
|
||||||
|
action = gtk_file_chooser_get_action (GTK_FILE_CHOOSER (dialog));
|
||||||
|
|
||||||
|
switch (action)
|
||||||
|
{
|
||||||
|
case GTK_FILE_CHOOSER_ACTION_OPEN:
|
||||||
|
g_object_set (dialog->option_menu,
|
||||||
|
"save_mode", FALSE,
|
||||||
|
NULL);
|
||||||
|
gtk_widget_show (dialog->option_menu);
|
||||||
|
break;
|
||||||
|
case GTK_FILE_CHOOSER_ACTION_SAVE:
|
||||||
|
g_object_set (dialog->option_menu,
|
||||||
|
"save_mode", TRUE,
|
||||||
|
NULL);
|
||||||
|
gtk_widget_show (dialog->option_menu);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
gtk_widget_hide (dialog->option_menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
update_newline_visibility (dialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gedit_file_chooser_dialog_gtk_init (GeditFileChooserDialogGtk *dialog)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
GeditFileChooserDialog *
|
||||||
|
gedit_file_chooser_dialog_gtk_create (const gchar *title,
|
||||||
|
GtkWindow *parent,
|
||||||
|
const gchar *accept_label,
|
||||||
|
const gchar *cancel_label)
|
||||||
|
{
|
||||||
|
GeditFileChooserDialogGtk *result;
|
||||||
|
|
||||||
|
result = g_object_new (GEDIT_TYPE_FILE_CHOOSER_DIALOG_GTK,
|
||||||
|
"title", title,
|
||||||
|
"local-only", FALSE,
|
||||||
|
"action", GTK_FILE_CHOOSER_ACTION_SAVE,
|
||||||
|
"select-multiple", FALSE,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
create_extra_widget (result);
|
||||||
|
|
||||||
|
g_signal_connect (result,
|
||||||
|
"notify::action",
|
||||||
|
G_CALLBACK (action_changed),
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
/* FIXME: attention, there is a ref cycle here. This will be fixed when
|
||||||
|
* GeditFileChooserSave will be created (and this class removed).
|
||||||
|
*/
|
||||||
|
result->gedit_file_chooser = _gedit_file_chooser_new ();
|
||||||
|
_gedit_file_chooser_set_gtk_file_chooser (result->gedit_file_chooser,
|
||||||
|
GTK_FILE_CHOOSER (result));
|
||||||
|
|
||||||
|
if (parent != NULL)
|
||||||
|
{
|
||||||
|
gtk_window_set_transient_for (GTK_WINDOW (result), parent);
|
||||||
|
gtk_window_set_destroy_with_parent (GTK_WINDOW (result), TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_dialog_add_button (GTK_DIALOG (result), cancel_label, GTK_RESPONSE_CANCEL);
|
||||||
|
gtk_dialog_add_button (GTK_DIALOG (result), accept_label, GTK_RESPONSE_ACCEPT);
|
||||||
|
gtk_dialog_set_default_response (GTK_DIALOG (result), GTK_RESPONSE_ACCEPT);
|
||||||
|
|
||||||
|
return GEDIT_FILE_CHOOSER_DIALOG (result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ex:set ts=8 noet: */
|
45
gedit/gedit-file-chooser-dialog-gtk.h
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
/*
|
||||||
|
* gedit-file-chooser-dialog-gtk.h
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 2005 - Paolo Maggi
|
||||||
|
* Copyright (C) 2014 - Jesse van den Kieboom
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GEDIT_FILE_CHOOSER_DIALOG_GTK_H
|
||||||
|
#define GEDIT_FILE_CHOOSER_DIALOG_GTK_H
|
||||||
|
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
#include "gedit-file-chooser-dialog.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define GEDIT_TYPE_FILE_CHOOSER_DIALOG_GTK (gedit_file_chooser_dialog_gtk_get_type ())
|
||||||
|
|
||||||
|
G_DECLARE_FINAL_TYPE (GeditFileChooserDialogGtk, gedit_file_chooser_dialog_gtk,
|
||||||
|
GEDIT, FILE_CHOOSER_DIALOG_GTK,
|
||||||
|
GtkFileChooserDialog)
|
||||||
|
|
||||||
|
GeditFileChooserDialog * gedit_file_chooser_dialog_gtk_create (const gchar *title,
|
||||||
|
GtkWindow *parent,
|
||||||
|
const gchar *accept_label,
|
||||||
|
const gchar *cancel_label);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* GEDIT_FILE_CHOOSER_DIALOG_GTK_H */
|
||||||
|
|
||||||
|
/* ex:set ts=8 noet: */
|
258
gedit/gedit-file-chooser-dialog.c
Normal file
|
@ -0,0 +1,258 @@
|
||||||
|
/*
|
||||||
|
* gedit-app-file-chooser-dialog.h
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 2014 Jesse van den Kieboom
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "gedit-file-chooser-dialog.h"
|
||||||
|
#include "gedit-file-chooser-dialog-gtk.h"
|
||||||
|
|
||||||
|
G_DEFINE_INTERFACE (GeditFileChooserDialog, gedit_file_chooser_dialog, G_TYPE_OBJECT)
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
confirm_overwrite_accumulator (GSignalInvocationHint *ihint,
|
||||||
|
GValue *return_accu,
|
||||||
|
const GValue *handler_return,
|
||||||
|
gpointer dummy)
|
||||||
|
{
|
||||||
|
gboolean continue_emission;
|
||||||
|
GtkFileChooserConfirmation conf;
|
||||||
|
|
||||||
|
conf = g_value_get_enum (handler_return);
|
||||||
|
g_value_set_enum (return_accu, conf);
|
||||||
|
continue_emission = (conf == GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM);
|
||||||
|
|
||||||
|
return continue_emission;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gedit_file_chooser_dialog_default_init (GeditFileChooserDialogInterface *iface)
|
||||||
|
{
|
||||||
|
g_signal_new ("response",
|
||||||
|
G_TYPE_FROM_INTERFACE (iface),
|
||||||
|
G_SIGNAL_RUN_LAST,
|
||||||
|
0,
|
||||||
|
NULL, NULL, NULL,
|
||||||
|
G_TYPE_NONE,
|
||||||
|
1,
|
||||||
|
G_TYPE_INT);
|
||||||
|
|
||||||
|
g_signal_new ("confirm-overwrite",
|
||||||
|
G_TYPE_FROM_INTERFACE (iface),
|
||||||
|
G_SIGNAL_RUN_LAST,
|
||||||
|
0,
|
||||||
|
confirm_overwrite_accumulator, NULL, NULL,
|
||||||
|
GTK_TYPE_FILE_CHOOSER_CONFIRMATION,
|
||||||
|
0);
|
||||||
|
}
|
||||||
|
|
||||||
|
GeditFileChooserDialog *
|
||||||
|
gedit_file_chooser_dialog_create (const gchar *title,
|
||||||
|
GtkWindow *parent,
|
||||||
|
const gchar *accept_label,
|
||||||
|
const gchar *cancel_label)
|
||||||
|
{
|
||||||
|
return gedit_file_chooser_dialog_gtk_create (title,
|
||||||
|
parent,
|
||||||
|
accept_label,
|
||||||
|
cancel_label);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gedit_file_chooser_dialog_set_encoding (GeditFileChooserDialog *dialog,
|
||||||
|
const GtkSourceEncoding *encoding)
|
||||||
|
{
|
||||||
|
GeditFileChooserDialogInterface *iface;
|
||||||
|
|
||||||
|
g_return_if_fail (GEDIT_IS_FILE_CHOOSER_DIALOG (dialog));
|
||||||
|
|
||||||
|
iface = GEDIT_FILE_CHOOSER_DIALOG_GET_IFACE (dialog);
|
||||||
|
g_return_if_fail (iface->set_encoding != NULL);
|
||||||
|
|
||||||
|
iface->set_encoding (dialog, encoding);
|
||||||
|
}
|
||||||
|
|
||||||
|
const GtkSourceEncoding *
|
||||||
|
gedit_file_chooser_dialog_get_encoding (GeditFileChooserDialog *dialog)
|
||||||
|
{
|
||||||
|
GeditFileChooserDialogInterface *iface;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GEDIT_IS_FILE_CHOOSER_DIALOG (dialog), NULL);
|
||||||
|
|
||||||
|
iface = GEDIT_FILE_CHOOSER_DIALOG_GET_IFACE (dialog);
|
||||||
|
g_return_val_if_fail (iface->get_encoding != NULL, NULL);
|
||||||
|
|
||||||
|
return iface->get_encoding (dialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gedit_file_chooser_dialog_set_newline_type (GeditFileChooserDialog *dialog,
|
||||||
|
GtkSourceNewlineType newline_type)
|
||||||
|
{
|
||||||
|
GeditFileChooserDialogInterface *iface;
|
||||||
|
|
||||||
|
g_return_if_fail (GEDIT_IS_FILE_CHOOSER_DIALOG (dialog));
|
||||||
|
|
||||||
|
iface = GEDIT_FILE_CHOOSER_DIALOG_GET_IFACE (dialog);
|
||||||
|
g_return_if_fail (iface->set_newline_type != NULL);
|
||||||
|
|
||||||
|
iface->set_newline_type (dialog, newline_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkSourceNewlineType
|
||||||
|
gedit_file_chooser_dialog_get_newline_type (GeditFileChooserDialog *dialog)
|
||||||
|
{
|
||||||
|
GeditFileChooserDialogInterface *iface;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GEDIT_IS_FILE_CHOOSER_DIALOG (dialog), GTK_SOURCE_NEWLINE_TYPE_DEFAULT);
|
||||||
|
|
||||||
|
iface = GEDIT_FILE_CHOOSER_DIALOG_GET_IFACE (dialog);
|
||||||
|
g_return_val_if_fail (iface->get_newline_type != NULL, GTK_SOURCE_NEWLINE_TYPE_DEFAULT);
|
||||||
|
|
||||||
|
return iface->get_newline_type (dialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
gedit_file_chooser_dialog_set_current_folder (GeditFileChooserDialog *dialog,
|
||||||
|
GFile *folder)
|
||||||
|
{
|
||||||
|
GeditFileChooserDialogInterface *iface;
|
||||||
|
|
||||||
|
g_return_if_fail (GEDIT_IS_FILE_CHOOSER_DIALOG (dialog));
|
||||||
|
|
||||||
|
iface = GEDIT_FILE_CHOOSER_DIALOG_GET_IFACE (dialog);
|
||||||
|
g_return_if_fail (iface->set_current_folder != NULL);
|
||||||
|
|
||||||
|
iface->set_current_folder (dialog, folder);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gedit_file_chooser_dialog_set_current_name (GeditFileChooserDialog *dialog,
|
||||||
|
const gchar *name)
|
||||||
|
{
|
||||||
|
GeditFileChooserDialogInterface *iface;
|
||||||
|
|
||||||
|
g_return_if_fail (GEDIT_IS_FILE_CHOOSER_DIALOG (dialog));
|
||||||
|
|
||||||
|
iface = GEDIT_FILE_CHOOSER_DIALOG_GET_IFACE (dialog);
|
||||||
|
g_return_if_fail (iface->set_current_name != NULL);
|
||||||
|
|
||||||
|
iface->set_current_name (dialog, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gedit_file_chooser_dialog_set_file (GeditFileChooserDialog *dialog,
|
||||||
|
GFile *file)
|
||||||
|
{
|
||||||
|
GeditFileChooserDialogInterface *iface;
|
||||||
|
|
||||||
|
g_return_if_fail (GEDIT_IS_FILE_CHOOSER_DIALOG (dialog));
|
||||||
|
g_return_if_fail (file == NULL || G_IS_FILE (file));
|
||||||
|
|
||||||
|
iface = GEDIT_FILE_CHOOSER_DIALOG_GET_IFACE (dialog);
|
||||||
|
g_return_if_fail (iface->set_file != NULL);
|
||||||
|
|
||||||
|
iface->set_file (dialog, file);
|
||||||
|
}
|
||||||
|
|
||||||
|
GFile *
|
||||||
|
gedit_file_chooser_dialog_get_file (GeditFileChooserDialog *dialog)
|
||||||
|
{
|
||||||
|
GeditFileChooserDialogInterface *iface;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GEDIT_IS_FILE_CHOOSER_DIALOG (dialog), NULL);
|
||||||
|
|
||||||
|
iface = GEDIT_FILE_CHOOSER_DIALOG_GET_IFACE (dialog);
|
||||||
|
g_return_val_if_fail (iface->get_file != NULL, NULL);
|
||||||
|
|
||||||
|
return iface->get_file (dialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gedit_file_chooser_dialog_set_do_overwrite_confirmation (GeditFileChooserDialog *dialog,
|
||||||
|
gboolean overwrite_confirmation)
|
||||||
|
{
|
||||||
|
GeditFileChooserDialogInterface *iface;
|
||||||
|
|
||||||
|
g_return_if_fail (GEDIT_IS_FILE_CHOOSER_DIALOG (dialog));
|
||||||
|
|
||||||
|
iface = GEDIT_FILE_CHOOSER_DIALOG_GET_IFACE (dialog);
|
||||||
|
g_return_if_fail (iface->set_do_overwrite_confirmation != NULL);
|
||||||
|
|
||||||
|
iface->set_do_overwrite_confirmation (dialog, overwrite_confirmation);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gedit_file_chooser_dialog_show (GeditFileChooserDialog *dialog)
|
||||||
|
{
|
||||||
|
GeditFileChooserDialogInterface *iface;
|
||||||
|
|
||||||
|
g_return_if_fail (GEDIT_IS_FILE_CHOOSER_DIALOG (dialog));
|
||||||
|
|
||||||
|
iface = GEDIT_FILE_CHOOSER_DIALOG_GET_IFACE (dialog);
|
||||||
|
g_return_if_fail (iface->show != NULL);
|
||||||
|
|
||||||
|
iface->show (dialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gedit_file_chooser_dialog_destroy (GeditFileChooserDialog *dialog)
|
||||||
|
{
|
||||||
|
GeditFileChooserDialogInterface *iface;
|
||||||
|
|
||||||
|
g_return_if_fail (GEDIT_IS_FILE_CHOOSER_DIALOG (dialog));
|
||||||
|
|
||||||
|
iface = GEDIT_FILE_CHOOSER_DIALOG_GET_IFACE (dialog);
|
||||||
|
g_return_if_fail (iface->destroy != NULL);
|
||||||
|
|
||||||
|
iface->destroy (dialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gedit_file_chooser_dialog_set_modal (GeditFileChooserDialog *dialog,
|
||||||
|
gboolean is_modal)
|
||||||
|
{
|
||||||
|
GeditFileChooserDialogInterface *iface;
|
||||||
|
|
||||||
|
g_return_if_fail (GEDIT_IS_FILE_CHOOSER_DIALOG (dialog));
|
||||||
|
|
||||||
|
iface = GEDIT_FILE_CHOOSER_DIALOG_GET_IFACE (dialog);
|
||||||
|
g_return_if_fail (iface->set_modal != NULL);
|
||||||
|
|
||||||
|
iface->set_modal (dialog, is_modal);
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkWindow *
|
||||||
|
gedit_file_chooser_dialog_get_window (GeditFileChooserDialog *dialog)
|
||||||
|
{
|
||||||
|
GeditFileChooserDialogInterface *iface;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GEDIT_IS_FILE_CHOOSER_DIALOG (dialog), NULL);
|
||||||
|
|
||||||
|
iface = GEDIT_FILE_CHOOSER_DIALOG_GET_IFACE (dialog);
|
||||||
|
|
||||||
|
if (iface->get_window)
|
||||||
|
{
|
||||||
|
return iface->get_window (dialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ex:set ts=8 noet: */
|
123
gedit/gedit-file-chooser-dialog.h
Normal file
|
@ -0,0 +1,123 @@
|
||||||
|
/*
|
||||||
|
* gedit-file-chooser-dialog.h
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 2014 - Jesse van den Kieboom
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GEDIT_FILE_CHOOSER_DIALOG_H
|
||||||
|
#define GEDIT_FILE_CHOOSER_DIALOG_H
|
||||||
|
|
||||||
|
#include <gtksourceview/gtksource.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define GEDIT_TYPE_FILE_CHOOSER_DIALOG (gedit_file_chooser_dialog_get_type ())
|
||||||
|
|
||||||
|
G_DECLARE_INTERFACE (GeditFileChooserDialog, gedit_file_chooser_dialog,
|
||||||
|
GEDIT, FILE_CHOOSER_DIALOG,
|
||||||
|
GObject)
|
||||||
|
|
||||||
|
struct _GeditFileChooserDialogInterface
|
||||||
|
{
|
||||||
|
GTypeInterface g_iface;
|
||||||
|
|
||||||
|
/* Virtual public methods */
|
||||||
|
void (*set_encoding) (GeditFileChooserDialog *dialog,
|
||||||
|
const GtkSourceEncoding *encoding);
|
||||||
|
|
||||||
|
const GtkSourceEncoding *
|
||||||
|
(*get_encoding) (GeditFileChooserDialog *dialog);
|
||||||
|
|
||||||
|
void (*set_newline_type) (GeditFileChooserDialog *dialog,
|
||||||
|
GtkSourceNewlineType newline_type);
|
||||||
|
|
||||||
|
GtkSourceNewlineType
|
||||||
|
(*get_newline_type) (GeditFileChooserDialog *dialog);
|
||||||
|
|
||||||
|
void (*set_current_folder) (GeditFileChooserDialog *dialog,
|
||||||
|
GFile *folder);
|
||||||
|
|
||||||
|
void (*set_current_name) (GeditFileChooserDialog *dialog,
|
||||||
|
const gchar *name);
|
||||||
|
|
||||||
|
void (*set_file) (GeditFileChooserDialog *dialog,
|
||||||
|
GFile *file);
|
||||||
|
|
||||||
|
GFile * (*get_file) (GeditFileChooserDialog *dialog);
|
||||||
|
|
||||||
|
void (*set_do_overwrite_confirmation)
|
||||||
|
(GeditFileChooserDialog *dialog,
|
||||||
|
gboolean overwrite_confirmation);
|
||||||
|
|
||||||
|
void (*show) (GeditFileChooserDialog *dialog);
|
||||||
|
|
||||||
|
void (*destroy) (GeditFileChooserDialog *dialog);
|
||||||
|
|
||||||
|
void (*set_modal) (GeditFileChooserDialog *dialog,
|
||||||
|
gboolean is_modal);
|
||||||
|
|
||||||
|
GtkWindow *
|
||||||
|
(*get_window) (GeditFileChooserDialog *dialog);
|
||||||
|
};
|
||||||
|
|
||||||
|
GeditFileChooserDialog *
|
||||||
|
gedit_file_chooser_dialog_create (const gchar *title,
|
||||||
|
GtkWindow *parent,
|
||||||
|
const gchar *accept_label,
|
||||||
|
const gchar *cancel_label);
|
||||||
|
|
||||||
|
void gedit_file_chooser_dialog_destroy (GeditFileChooserDialog *dialog);
|
||||||
|
|
||||||
|
void gedit_file_chooser_dialog_set_encoding (GeditFileChooserDialog *dialog,
|
||||||
|
const GtkSourceEncoding *encoding);
|
||||||
|
|
||||||
|
const GtkSourceEncoding *
|
||||||
|
gedit_file_chooser_dialog_get_encoding (GeditFileChooserDialog *dialog);
|
||||||
|
|
||||||
|
void gedit_file_chooser_dialog_set_newline_type (GeditFileChooserDialog *dialog,
|
||||||
|
GtkSourceNewlineType newline_type);
|
||||||
|
|
||||||
|
GtkSourceNewlineType
|
||||||
|
gedit_file_chooser_dialog_get_newline_type (GeditFileChooserDialog *dialog);
|
||||||
|
|
||||||
|
void gedit_file_chooser_dialog_set_current_folder (GeditFileChooserDialog *dialog,
|
||||||
|
GFile *folder);
|
||||||
|
|
||||||
|
void gedit_file_chooser_dialog_set_current_name (GeditFileChooserDialog *dialog,
|
||||||
|
const gchar *name);
|
||||||
|
|
||||||
|
void gedit_file_chooser_dialog_set_file (GeditFileChooserDialog *dialog,
|
||||||
|
GFile *file);
|
||||||
|
|
||||||
|
GFile *gedit_file_chooser_dialog_get_file (GeditFileChooserDialog *dialog);
|
||||||
|
|
||||||
|
void gedit_file_chooser_dialog_set_do_overwrite_confirmation (
|
||||||
|
GeditFileChooserDialog *dialog,
|
||||||
|
gboolean overwrite_confirmation);
|
||||||
|
|
||||||
|
void gedit_file_chooser_dialog_show (GeditFileChooserDialog *dialog);
|
||||||
|
|
||||||
|
void gedit_file_chooser_dialog_set_modal (GeditFileChooserDialog *dialog,
|
||||||
|
gboolean is_modal);
|
||||||
|
|
||||||
|
GtkWindow *gedit_file_chooser_dialog_get_window (GeditFileChooserDialog *dialog);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* GEDIT_FILE_CHOOSER_DIALOG_H */
|
||||||
|
|
||||||
|
/* ex:set ts=8 noet: */
|
125
gedit/gedit-file-chooser-open-dialog.c
Normal file
|
@ -0,0 +1,125 @@
|
||||||
|
/*
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020 Sébastien Wilmet <swilmet@gnome.org>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "gedit-file-chooser-open-dialog.h"
|
||||||
|
#include <glib/gi18n.h>
|
||||||
|
#include "gedit-encodings-combo-box.h"
|
||||||
|
|
||||||
|
/* A GtkFileChooserDialog to *open* files. */
|
||||||
|
|
||||||
|
struct _GeditFileChooserOpenDialogPrivate
|
||||||
|
{
|
||||||
|
GeditEncodingsComboBox *encodings_combo_box;
|
||||||
|
};
|
||||||
|
|
||||||
|
G_DEFINE_TYPE_WITH_PRIVATE (GeditFileChooserOpenDialog, _gedit_file_chooser_open_dialog, GEDIT_TYPE_FILE_CHOOSER_OPEN)
|
||||||
|
|
||||||
|
static void
|
||||||
|
setup_encoding_extra_widget (GeditFileChooserOpenDialog *chooser,
|
||||||
|
GtkFileChooser *gtk_chooser)
|
||||||
|
{
|
||||||
|
GtkWidget *label;
|
||||||
|
GtkWidget *encodings_combo_box;
|
||||||
|
GtkWidget *hgrid;
|
||||||
|
|
||||||
|
g_assert (chooser->priv->encodings_combo_box == NULL);
|
||||||
|
|
||||||
|
label = gtk_label_new_with_mnemonic (_("C_haracter Encoding:"));
|
||||||
|
encodings_combo_box = gedit_encodings_combo_box_new (FALSE);
|
||||||
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), encodings_combo_box);
|
||||||
|
|
||||||
|
hgrid = gtk_grid_new ();
|
||||||
|
gtk_grid_set_column_spacing (GTK_GRID (hgrid), 6);
|
||||||
|
gtk_container_add (GTK_CONTAINER (hgrid), label);
|
||||||
|
gtk_container_add (GTK_CONTAINER (hgrid), encodings_combo_box);
|
||||||
|
|
||||||
|
chooser->priv->encodings_combo_box = GEDIT_ENCODINGS_COMBO_BOX (encodings_combo_box);
|
||||||
|
g_object_ref_sink (chooser->priv->encodings_combo_box);
|
||||||
|
|
||||||
|
gtk_widget_show_all (hgrid);
|
||||||
|
gtk_file_chooser_set_extra_widget (gtk_chooser, hgrid);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_gedit_file_chooser_open_dialog_dispose (GObject *object)
|
||||||
|
{
|
||||||
|
GeditFileChooserOpenDialog *chooser = GEDIT_FILE_CHOOSER_OPEN_DIALOG (object);
|
||||||
|
|
||||||
|
g_clear_object (&chooser->priv->encodings_combo_box);
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (_gedit_file_chooser_open_dialog_parent_class)->dispose (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static GtkFileChooser *
|
||||||
|
chooser_create_gtk_file_chooser (GeditFileChooser *chooser)
|
||||||
|
{
|
||||||
|
GtkWidget *file_chooser;
|
||||||
|
|
||||||
|
/* Translators: "Open Files" is the title of the file chooser window. */
|
||||||
|
file_chooser = gtk_file_chooser_dialog_new (C_("window title", "Open Files"),
|
||||||
|
NULL,
|
||||||
|
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||||
|
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
||||||
|
_("_Open"), GTK_RESPONSE_ACCEPT,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
gtk_dialog_set_default_response (GTK_DIALOG (file_chooser), GTK_RESPONSE_ACCEPT);
|
||||||
|
|
||||||
|
setup_encoding_extra_widget (GEDIT_FILE_CHOOSER_OPEN_DIALOG (chooser),
|
||||||
|
GTK_FILE_CHOOSER (file_chooser));
|
||||||
|
|
||||||
|
if (g_object_is_floating (file_chooser))
|
||||||
|
{
|
||||||
|
g_object_ref_sink (file_chooser);
|
||||||
|
}
|
||||||
|
|
||||||
|
return GTK_FILE_CHOOSER (file_chooser);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const GtkSourceEncoding *
|
||||||
|
chooser_get_encoding (GeditFileChooser *_chooser)
|
||||||
|
{
|
||||||
|
GeditFileChooserOpenDialog *chooser = GEDIT_FILE_CHOOSER_OPEN_DIALOG (_chooser);
|
||||||
|
|
||||||
|
return gedit_encodings_combo_box_get_selected_encoding (chooser->priv->encodings_combo_box);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_gedit_file_chooser_open_dialog_class_init (GeditFileChooserOpenDialogClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
GeditFileChooserClass *file_chooser_class = GEDIT_FILE_CHOOSER_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->dispose = _gedit_file_chooser_open_dialog_dispose;
|
||||||
|
|
||||||
|
file_chooser_class->create_gtk_file_chooser = chooser_create_gtk_file_chooser;
|
||||||
|
file_chooser_class->get_encoding = chooser_get_encoding;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_gedit_file_chooser_open_dialog_init (GeditFileChooserOpenDialog *chooser)
|
||||||
|
{
|
||||||
|
chooser->priv = _gedit_file_chooser_open_dialog_get_instance_private (chooser);
|
||||||
|
}
|
||||||
|
|
||||||
|
GeditFileChooserOpen *
|
||||||
|
_gedit_file_chooser_open_dialog_new (void)
|
||||||
|
{
|
||||||
|
return g_object_new (GEDIT_TYPE_FILE_CHOOSER_OPEN_DIALOG, NULL);
|
||||||
|
}
|
58
gedit/gedit-file-chooser-open-dialog.h
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
/*
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020 Sébastien Wilmet <swilmet@gnome.org>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GEDIT_FILE_CHOOSER_OPEN_DIALOG_H
|
||||||
|
#define GEDIT_FILE_CHOOSER_OPEN_DIALOG_H
|
||||||
|
|
||||||
|
#include "gedit-file-chooser-open.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define GEDIT_TYPE_FILE_CHOOSER_OPEN_DIALOG (_gedit_file_chooser_open_dialog_get_type ())
|
||||||
|
#define GEDIT_FILE_CHOOSER_OPEN_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_FILE_CHOOSER_OPEN_DIALOG, GeditFileChooserOpenDialog))
|
||||||
|
#define GEDIT_FILE_CHOOSER_OPEN_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEDIT_TYPE_FILE_CHOOSER_OPEN_DIALOG, GeditFileChooserOpenDialogClass))
|
||||||
|
#define GEDIT_IS_FILE_CHOOSER_OPEN_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEDIT_TYPE_FILE_CHOOSER_OPEN_DIALOG))
|
||||||
|
#define GEDIT_IS_FILE_CHOOSER_OPEN_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_FILE_CHOOSER_OPEN_DIALOG))
|
||||||
|
#define GEDIT_FILE_CHOOSER_OPEN_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEDIT_TYPE_FILE_CHOOSER_OPEN_DIALOG, GeditFileChooserOpenDialogClass))
|
||||||
|
|
||||||
|
typedef struct _GeditFileChooserOpenDialog GeditFileChooserOpenDialog;
|
||||||
|
typedef struct _GeditFileChooserOpenDialogClass GeditFileChooserOpenDialogClass;
|
||||||
|
typedef struct _GeditFileChooserOpenDialogPrivate GeditFileChooserOpenDialogPrivate;
|
||||||
|
|
||||||
|
struct _GeditFileChooserOpenDialog
|
||||||
|
{
|
||||||
|
GeditFileChooserOpen parent;
|
||||||
|
|
||||||
|
GeditFileChooserOpenDialogPrivate *priv;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GeditFileChooserOpenDialogClass
|
||||||
|
{
|
||||||
|
GeditFileChooserOpenClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
G_GNUC_INTERNAL
|
||||||
|
GType _gedit_file_chooser_open_dialog_get_type (void);
|
||||||
|
|
||||||
|
G_GNUC_INTERNAL
|
||||||
|
GeditFileChooserOpen * _gedit_file_chooser_open_dialog_new (void);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* GEDIT_FILE_CHOOSER_OPEN_DIALOG_H */
|
84
gedit/gedit-file-chooser-open-native.c
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
/*
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020 Sébastien Wilmet <swilmet@gnome.org>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "gedit-file-chooser-open-native.h"
|
||||||
|
#include <glib/gi18n.h>
|
||||||
|
|
||||||
|
/* A GtkFileChooserNative to *open* files. */
|
||||||
|
/* TODO: finish the implementation. */
|
||||||
|
|
||||||
|
struct _GeditFileChooserOpenNativePrivate
|
||||||
|
{
|
||||||
|
gint something;
|
||||||
|
};
|
||||||
|
|
||||||
|
G_DEFINE_TYPE_WITH_PRIVATE (GeditFileChooserOpenNative, _gedit_file_chooser_open_native, GEDIT_TYPE_FILE_CHOOSER_OPEN)
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
static GtkNativeDialog *
|
||||||
|
get_native_dialog (GeditFileChooserOpenNative *chooser)
|
||||||
|
{
|
||||||
|
return GTK_NATIVE_DIALOG (_gedit_file_chooser_get_gtk_file_chooser (GEDIT_FILE_CHOOSER (chooser)));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static void
|
||||||
|
_gedit_file_chooser_open_native_dispose (GObject *object)
|
||||||
|
{
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (_gedit_file_chooser_open_native_parent_class)->dispose (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static GtkFileChooser *
|
||||||
|
chooser_create_gtk_file_chooser (GeditFileChooser *chooser)
|
||||||
|
{
|
||||||
|
GtkFileChooserNative *native_chooser;
|
||||||
|
|
||||||
|
/* Translators: "Open Files" is the title of the file chooser window. */
|
||||||
|
native_chooser = gtk_file_chooser_native_new (C_("window title", "Open Files"),
|
||||||
|
NULL,
|
||||||
|
GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
return GTK_FILE_CHOOSER (native_chooser);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_gedit_file_chooser_open_native_class_init (GeditFileChooserOpenNativeClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
GeditFileChooserClass *chooser_class = GEDIT_FILE_CHOOSER_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->dispose = _gedit_file_chooser_open_native_dispose;
|
||||||
|
|
||||||
|
chooser_class->create_gtk_file_chooser = chooser_create_gtk_file_chooser;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_gedit_file_chooser_open_native_init (GeditFileChooserOpenNative *chooser)
|
||||||
|
{
|
||||||
|
chooser->priv = _gedit_file_chooser_open_native_get_instance_private (chooser);
|
||||||
|
}
|
||||||
|
|
||||||
|
GeditFileChooserOpen *
|
||||||
|
_gedit_file_chooser_open_native_new (void)
|
||||||
|
{
|
||||||
|
return g_object_new (GEDIT_TYPE_FILE_CHOOSER_OPEN_NATIVE, NULL);
|
||||||
|
}
|
58
gedit/gedit-file-chooser-open-native.h
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
/*
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020 Sébastien Wilmet <swilmet@gnome.org>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GEDIT_FILE_CHOOSER_OPEN_NATIVE_H
|
||||||
|
#define GEDIT_FILE_CHOOSER_OPEN_NATIVE_H
|
||||||
|
|
||||||
|
#include "gedit-file-chooser-open.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define GEDIT_TYPE_FILE_CHOOSER_OPEN_NATIVE (_gedit_file_chooser_open_native_get_type ())
|
||||||
|
#define GEDIT_FILE_CHOOSER_OPEN_NATIVE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_FILE_CHOOSER_OPEN_NATIVE, GeditFileChooserOpenNative))
|
||||||
|
#define GEDIT_FILE_CHOOSER_OPEN_NATIVE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEDIT_TYPE_FILE_CHOOSER_OPEN_NATIVE, GeditFileChooserOpenNativeClass))
|
||||||
|
#define GEDIT_IS_FILE_CHOOSER_OPEN_NATIVE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEDIT_TYPE_FILE_CHOOSER_OPEN_NATIVE))
|
||||||
|
#define GEDIT_IS_FILE_CHOOSER_OPEN_NATIVE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_FILE_CHOOSER_OPEN_NATIVE))
|
||||||
|
#define GEDIT_FILE_CHOOSER_OPEN_NATIVE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEDIT_TYPE_FILE_CHOOSER_OPEN_NATIVE, GeditFileChooserOpenNativeClass))
|
||||||
|
|
||||||
|
typedef struct _GeditFileChooserOpenNative GeditFileChooserOpenNative;
|
||||||
|
typedef struct _GeditFileChooserOpenNativeClass GeditFileChooserOpenNativeClass;
|
||||||
|
typedef struct _GeditFileChooserOpenNativePrivate GeditFileChooserOpenNativePrivate;
|
||||||
|
|
||||||
|
struct _GeditFileChooserOpenNative
|
||||||
|
{
|
||||||
|
GeditFileChooserOpen parent;
|
||||||
|
|
||||||
|
GeditFileChooserOpenNativePrivate *priv;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GeditFileChooserOpenNativeClass
|
||||||
|
{
|
||||||
|
GeditFileChooserOpenClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
G_GNUC_INTERNAL
|
||||||
|
GType _gedit_file_chooser_open_native_get_type (void);
|
||||||
|
|
||||||
|
G_GNUC_INTERNAL
|
||||||
|
GeditFileChooserOpen * _gedit_file_chooser_open_native_new (void);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* GEDIT_FILE_CHOOSER_OPEN_NATIVE_H */
|
77
gedit/gedit-file-chooser-open.c
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
/*
|
||||||
|
* This file is part of gedit
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020 Sébastien Wilmet <swilmet@gnome.org>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "gedit-file-chooser-open.h"
|
||||||
|
#include "gedit-file-chooser-open-dialog.h"
|
||||||
|
#include "gedit-file-chooser-open-native.h"
|
||||||
|
|
||||||
|
/* Common code for file choosers that *open* files. */
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (GeditFileChooserOpen, _gedit_file_chooser_open, GEDIT_TYPE_FILE_CHOOSER)
|
||||||
|
|
||||||
|
static GtkFileChooser *
|
||||||
|
get_gtk_file_chooser (GeditFileChooserOpen *chooser)
|
||||||
|
{
|
||||||
|
return _gedit_file_chooser_get_gtk_file_chooser (GEDIT_FILE_CHOOSER (chooser));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_gedit_file_chooser_open_constructed (GObject *object)
|
||||||
|
{
|
||||||
|
GeditFileChooserOpen *chooser = GEDIT_FILE_CHOOSER_OPEN (object);
|
||||||
|
|
||||||
|
if (G_OBJECT_CLASS (_gedit_file_chooser_open_parent_class)->constructed != NULL)
|
||||||
|
{
|
||||||
|
G_OBJECT_CLASS (_gedit_file_chooser_open_parent_class)->constructed (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_file_chooser_set_select_multiple (get_gtk_file_chooser (chooser), TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_gedit_file_chooser_open_class_init (GeditFileChooserOpenClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->constructed = _gedit_file_chooser_open_constructed;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_gedit_file_chooser_open_init (GeditFileChooserOpen *chooser)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
GeditFileChooserOpen *
|
||||||
|
_gedit_file_chooser_open_new (void)
|
||||||
|
{
|
||||||
|
if (_gedit_file_chooser_is_native ())
|
||||||
|
{
|
||||||
|
return _gedit_file_chooser_open_native_new ();
|
||||||
|
}
|
||||||
|
|
||||||
|
return _gedit_file_chooser_open_dialog_new ();
|
||||||
|
}
|
||||||
|
|
||||||
|
GSList *
|
||||||
|
_gedit_file_chooser_open_get_files (GeditFileChooserOpen *chooser)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GEDIT_IS_FILE_CHOOSER_OPEN (chooser), NULL);
|
||||||
|
|
||||||
|
return gtk_file_chooser_get_files (get_gtk_file_chooser (chooser));
|
||||||
|
}
|