Add native GTK printing support.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@2050 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Enrico Tröger 2007-11-17 14:04:27 +00:00
parent 1672c377fe
commit fff66178da
21 changed files with 1877 additions and 329 deletions

View File

@ -3,6 +3,12 @@
* src/templates.c, src/utils.c, src/utils.h:
Fix possible memory leak and add time_t argument in
utils_get_date_time() to pass a time pointer to use.
* configure.in, geany.glade, TODO, doc/geany.html, doc/geany.txt,
src/callbacks.c, src/callbacks.h, src/document.c, src/document.h,
src/interface.c, src/keyfile.c, src/main.c, src/Makefile.am,
src/makefile.win32, src/prefs.c, src/prefs.h, src/printing.c,
src/printing.h, src/ui_utils.c, src/ui_utils.h:
Add native GTK printing support.
2007-11-14 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>

1
TODO
View File

@ -30,7 +30,6 @@ TODO List:
o (better tags support for popular languages? - this is a moving
target...)
o (tango-like icons for the symbol list)
o (GTK+ 2.10 printing support)
o (show autocompletion symbol icons - see SCI_REGISTERIMAGE)

View File

@ -85,7 +85,7 @@ AC_ARG_WITH(vte-module-path, AC_HELP_STRING([--with-vte-module-path=PATH],
# Plugins support
AC_ARG_ENABLE(plugins, [AC_HELP_STRING([--disable-plugins], [compile without plugin support])], , enable_plugins=yes)
AC_ARG_ENABLE(plugins, [AC_HELP_STRING([--disable-plugins], [compile without plugin support [[default=no]]])], , enable_plugins=yes)
if test "x$enable_plugins" = "xyes" ; then
AC_DEFINE(HAVE_PLUGINS, 1, [Define if plugins are enabled.])
@ -110,6 +110,16 @@ AM_CONDITIONAL(MINGW, test "x$host" = "xi386-mingw32msvc")
GTK_VERSION=`$PKG_CONFIG --modversion gtk+-2.0`
# GTK 2.10 printing support
$PKG_CONFIG --exists 'gtk+-2.0 >= 2.10.0'
if test "x$?" = "x0" ; then
enable_printing="yes"
else
enable_printing="no (GTK >= 2.10 necessary)"
fi
# just for a laugh (it has absolutely no effect)
AC_ARG_ENABLE(the-force, AC_HELP_STRING([--enable-the-force],
[enable if you are Luke Skywalker and the force is with you [[default=no]]]), [be_luke="$enableval"], [be_luke="no"])
@ -128,6 +138,7 @@ AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package.])
ALL_LINGUAS="`sed -e '/^#/d' $srcdir/po/LINGUAS`" # take all languages found in file po/LINGUAS
AM_GLIB_GNU_GETTEXT
# workaround for intltool bug (http://bugzilla.gnome.org/show_bug.cgi?id=490845)
if test "x$MSGFMT" = "xno"; then
AC_MSG_ERROR([msgfmt not found. Please install the gettext package.])
fi
@ -176,6 +187,7 @@ then
echo "Building Geany for : ${target}"
fi
echo "Using GTK version : ${GTK_VERSION}"
echo "Build with GTK printing support : ${enable_printing}"
echo "Build with plugin support : ${enable_plugins}"
echo "Use virtual terminal support : ${want_vte}"
echo "Use (UNIX domain) socket support : ${want_socket}"

View File

@ -6,7 +6,7 @@
<meta name="generator" content="Docutils 0.4.1: http://docutils.sourceforge.net/" />
<title>Geany</title>
<meta name="authors" content="Enrico Tröger Nick Treleaven Frank Lanitz" />
<meta name="date" content="2007-11-01" />
<meta name="date" content="2007-11-12" />
<style type="text/css">
/*
@ -133,7 +133,7 @@ dt {
<br />Nick Treleaven
<br />Frank Lanitz</td></tr>
<tr><th class="docinfo-name">Date:</th>
<td>2007-11-01</td></tr>
<td>2007-11-12</td></tr>
<tr><th class="docinfo-name">Version:</th>
<td>0.13</td></tr>
</tbody>
@ -1476,9 +1476,35 @@ dialog.</p>
</div>
<div class="section">
<h2><a class="toc-backref" href="#id80" id="printing-support" name="printing-support">Printing support</a></h2>
<p>Geany has basic printing support. This means you can print a file by
passing the filename of the current file to a command which actually
prints the file. However, the printed document contains no syntax
<p>Since Geany 0.13 there is full printing support using GTK's printing API.
The printed page(s) will look nearly the same as on your screen in Geany.
Additionally, there are some options to modify the printed page(s). You
can define whether to print line numbers, page numbers at the bottom of
each page and whether to print a page header on each page. This header
contains the filename of the printed document, the current page number and
the date and time of printing. By default, the file name of the document
is added with full path information to the header. If you prefer to add
only the basename of the file(without any path information) you can set it
in the preferences dialog. You can also adjust the format of the date and
time added to the page header. The available conversion specifiers are the
same as the ones which can be used with the ANSI C strftime function.
All of these settings can also be changed in the print dialog just before
actual printing is done.
On Unix-like systems the provided print dialog offers a print preview. The
preview file is opened with a PDF viewer and by default GTK uses <tt class="docutils literal"><span class="pre">evince</span></tt>
for print preview. If you don't have installed evince or just want to use
another PDF viewer, you can change the program to use in the file
<tt class="docutils literal"><span class="pre">.gtkrc-2.0</span></tt> (usually found in your home directory). Simply add a line
like:</p>
<pre class="literal-block">
gtk-print-preview-command = &quot;epdfview %f&quot;
</pre>
<p>at the end of the file. Of course, you can also use xpdf, kpdf or whatever.</p>
<p>Unfortunately, native GTK printing support is only available if Geany was
built against GTK 2.10 (or above) <strong>and</strong> is running with GTK 2.10 (or above).
If not, Geany provides basic printing support. This means you can print a
file by passing the filename of the current file to a command which
actually prints the file. However, the printed document contains no syntax
highlighting. You can adjust the command to which the filename is
passed in the preferences dialog. The default command is:</p>
<pre class="literal-block">
@ -1494,12 +1520,6 @@ command line).</p>
</pre>
<p>But this depends on a2ps and xfprint4. As a replacement for xfprint4,
gtklp or similar programs can be used.</p>
<div class="note">
<p class="first admonition-title">Note</p>
<p class="last">The printing support of Geany will be improved in the future. With
GTK 2.10, better printing (including syntax highlighting) will be
possible.</p>
</div>
</div>
<div class="section">
<h2><a class="toc-backref" href="#id81" id="plugins" name="plugins">Plugins</a></h2>
@ -3107,7 +3127,7 @@ USE OR PERFORMANCE OF THIS SOFTWARE.</p>
<div class="footer">
<hr class="footer" />
<a class="reference" href="geany.txt">View document source</a>.
Generated on: 2007-11-12 09:15 UTC.
Generated on: 2007-11-17 13:39 UTC.
Generated by <a class="reference" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
</div>

View File

@ -1368,9 +1368,37 @@ dialog.
Printing support
----------------
Geany has basic printing support. This means you can print a file by
passing the filename of the current file to a command which actually
prints the file. However, the printed document contains no syntax
Since Geany 0.13 there is full printing support using GTK's printing API.
The printed page(s) will look nearly the same as on your screen in Geany.
Additionally, there are some options to modify the printed page(s). You
can define whether to print line numbers, page numbers at the bottom of
each page and whether to print a page header on each page. This header
contains the filename of the printed document, the current page number and
the date and time of printing. By default, the file name of the document
is added with full path information to the header. If you prefer to add
only the basename of the file(without any path information) you can set it
in the preferences dialog. You can also adjust the format of the date and
time added to the page header. The available conversion specifiers are the
same as the ones which can be used with the ANSI C strftime function.
All of these settings can also be changed in the print dialog just before
actual printing is done.
On Unix-like systems the provided print dialog offers a print preview. The
preview file is opened with a PDF viewer and by default GTK uses ``evince``
for print preview. If you don't have installed evince or just want to use
another PDF viewer, you can change the program to use in the file
``.gtkrc-2.0`` (usually found in your home directory). Simply add a line
like::
gtk-print-preview-command = "epdfview %f"
at the end of the file. Of course, you can also use xpdf, kpdf or whatever
as the print preview command.
Unfortunately, native GTK printing support is only available if Geany was
built against GTK 2.10 (or above) **and** is running with GTK 2.10 (or above).
If not, Geany provides basic printing support. This means you can print a
file by passing the filename of the current file to a command which
actually prints the file. However, the printed document contains no syntax
highlighting. You can adjust the command to which the filename is
passed in the preferences dialog. The default command is::
@ -1388,11 +1416,6 @@ A nicer example, which I prefer is::
But this depends on a2ps and xfprint4. As a replacement for xfprint4,
gtklp or similar programs can be used.
.. note::
The printing support of Geany will be improved in the future. With
GTK 2.10, better printing (including syntax highlighting) will be
possible.
Plugins

View File

@ -58,7 +58,7 @@
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image2282">
<widget class="GtkImage" id="image2299">
<property name="visible">True</property>
<property name="stock">gtk-new</property>
<property name="icon_size">1</property>
@ -148,7 +148,7 @@
<signal name="activate" handler="on_save_all1_activate" last_modification_time="Thu, 02 Jun 2005 14:15:30 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image2283">
<widget class="GtkImage" id="image2300">
<property name="visible">True</property>
<property name="stock">gtk-save</property>
<property name="icon_size">1</property>
@ -169,7 +169,7 @@
<signal name="activate" handler="on_toolbutton23_clicked" last_modification_time="Mon, 24 Jul 2006 19:26:04 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image2284">
<widget class="GtkImage" id="image2301">
<property name="visible">True</property>
<property name="stock">gtk-revert-to-saved</property>
<property name="icon_size">1</property>
@ -189,7 +189,7 @@
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image2285">
<widget class="GtkImage" id="image2302">
<property name="visible">True</property>
<property name="stock">gtk-revert-to-saved</property>
<property name="icon_size">1</property>
@ -251,6 +251,15 @@
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="page_setup1">
<property name="visible">True</property>
<property name="label" translatable="yes">Page set_up</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_page_setup1_activate" last_modification_time="Thu, 15 Nov 2007 21:11:31 GMT"/>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="print1">
<property name="visible">True</property>
@ -285,7 +294,7 @@
<signal name="activate" handler="on_close_all1_activate" last_modification_time="Thu, 02 Jun 2005 14:15:30 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image2286">
<widget class="GtkImage" id="image2303">
<property name="visible">True</property>
<property name="stock">gtk-close</property>
<property name="icon_size">1</property>
@ -484,7 +493,7 @@
<signal name="activate" handler="on_menu_increase_indent1_activate" last_modification_time="Tue, 01 Aug 2006 10:28:54 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image2287">
<widget class="GtkImage" id="image2304">
<property name="visible">True</property>
<property name="stock">gtk-indent</property>
<property name="icon_size">1</property>
@ -505,7 +514,7 @@
<signal name="activate" handler="on_menu_decrease_indent1_activate" last_modification_time="Tue, 01 Aug 2006 10:28:54 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image2288">
<widget class="GtkImage" id="image2305">
<property name="visible">True</property>
<property name="stock">gtk-unindent</property>
<property name="icon_size">1</property>
@ -561,7 +570,7 @@
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image2289">
<widget class="GtkImage" id="image2306">
<property name="visible">True</property>
<property name="stock">gtk-add</property>
<property name="icon_size">1</property>
@ -646,7 +655,7 @@
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image2290">
<widget class="GtkImage" id="image2307">
<property name="visible">True</property>
<property name="stock">gtk-add</property>
<property name="icon_size">1</property>
@ -678,7 +687,7 @@
<property name="use_underline">True</property>
<child internal-child="image">
<widget class="GtkImage" id="image2291">
<widget class="GtkImage" id="image2308">
<property name="visible">True</property>
<property name="stock">gtk-add</property>
<property name="icon_size">1</property>
@ -775,7 +784,7 @@
<signal name="activate" handler="on_replace1_activate" last_modification_time="Sun, 23 Oct 2005 13:22:36 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image2292">
<widget class="GtkImage" id="image2309">
<property name="visible">True</property>
<property name="stock">gtk-find-and-replace</property>
<property name="icon_size">1</property>
@ -841,7 +850,7 @@
<signal name="activate" handler="on_go_to_line1_activate" last_modification_time="Tue, 23 May 2006 17:10:49 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image2293">
<widget class="GtkImage" id="image2310">
<property name="visible">True</property>
<property name="stock">gtk-jump-to</property>
<property name="icon_size">1</property>
@ -876,7 +885,7 @@
<signal name="activate" handler="on_change_font1_activate" last_modification_time="Fri, 22 Apr 2005 18:58:45 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image2294">
<widget class="GtkImage" id="image2311">
<property name="visible">True</property>
<property name="stock">gtk-select-font</property>
<property name="icon_size">1</property>
@ -1285,7 +1294,7 @@
<signal name="activate" handler="on_project_new1_activate" last_modification_time="Thu, 18 Jan 2007 22:16:24 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image2295">
<widget class="GtkImage" id="image2312">
<property name="visible">True</property>
<property name="stock">gtk-new</property>
<property name="icon_size">1</property>
@ -1306,7 +1315,7 @@
<signal name="activate" handler="on_project_open1_activate" last_modification_time="Mon, 15 Jan 2007 17:34:17 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image2296">
<widget class="GtkImage" id="image2313">
<property name="visible">True</property>
<property name="stock">gtk-open</property>
<property name="icon_size">1</property>
@ -1327,7 +1336,7 @@
<signal name="activate" handler="on_project_close1_activate" last_modification_time="Mon, 15 Jan 2007 17:34:17 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image2297">
<widget class="GtkImage" id="image2314">
<property name="visible">True</property>
<property name="stock">gtk-close</property>
<property name="icon_size">1</property>
@ -1385,7 +1394,7 @@
<signal name="activate" handler="on_show_color_chooser1_activate" last_modification_time="Wed, 22 Jun 2005 18:10:21 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image2298">
<widget class="GtkImage" id="image2315">
<property name="visible">True</property>
<property name="stock">gtk-select-color</property>
<property name="icon_size">1</property>
@ -1429,7 +1438,7 @@
<signal name="activate" handler="on_help1_activate" last_modification_time="Sun, 24 Jul 2005 15:23:11 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image2299">
<widget class="GtkImage" id="image2316">
<property name="visible">True</property>
<property name="stock">gtk-help</property>
<property name="icon_size">1</property>
@ -7077,66 +7086,15 @@ Match braces</property>
<property name="column_spacing">6</property>
<child>
<widget class="GtkEntry" id="entry_print">
<widget class="GtkLabel" id="label189">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Path to the command for printing files (use %f for the filename).</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">*</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button_print">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<child>
<widget class="GtkImage" id="image763">
<property name="visible">True</property>
<property name="stock">gtk-open</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label154">
<property name="visible">True</property>
<property name="label" translatable="yes">Print:</property>
<property name="label" translatable="yes">Context action:</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
@ -7171,36 +7129,8 @@ Match braces</property>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label189">
<property name="visible">True</property>
<property name="label" translatable="yes">Context action:</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="y_options"></property>
</packing>
</child>
@ -7227,8 +7157,8 @@ Match braces</property>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
@ -7859,6 +7789,418 @@ Match braces</property>
<property name="type">tab</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox27">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkFrame" id="frame32">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="label_yalign">0.5</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
<widget class="GtkAlignment" id="alignment35">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">1</property>
<property name="yscale">1</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">12</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkHBox" id="hbox9">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">5</property>
<child>
<widget class="GtkLabel" id="label202">
<property name="visible">True</property>
<property name="label" translatable="yes">Command:</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="entry_print_external_cmd">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Path to the command for printing files (use %f for the filename).</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">*</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button_print_external_cmd">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<child>
<widget class="GtkImage" id="image763">
<property name="visible">True</property>
<property name="stock">gtk-open</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkRadioButton" id="radio_print_external">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Use an external command for printing</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">False</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame31">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="label_yalign">0.5</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
<widget class="GtkAlignment" id="alignment34">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">1</property>
<property name="yscale">1</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">12</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkVBox" id="vbox29">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkCheckButton" id="check_print_linenumbers">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Add line numbers to the printed page.</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Print line numbers</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">False</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="check_print_pagenumbers">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Add page numbers at the bottom of each page. It takes 2 lines of the page.</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Print page numbers</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">False</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="check_print_pageheader">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Adds a little header to every page containing the page number, the filename and the current date(see below). It takes 3 lines of the page.</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Print page header</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">False</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkFrame" id="frame33">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="label_yalign">0</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
<widget class="GtkAlignment" id="alignment36">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xscale">1</property>
<property name="yscale">1</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">12</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkVBox" id="vbox30">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">1</property>
<child>
<widget class="GtkCheckButton" id="check_print_basename">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Print only the basename(without the path) of the printed file.</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Use the basename of the printed file</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">False</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox10">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">5</property>
<child>
<widget class="GtkLabel" id="label203">
<property name="visible">True</property>
<property name="label" translatable="yes">Date format:</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="entry_print_dateformat">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Specify a format for the date and time stamp which is added to the page header on each page. You can use any conversion specifiers which can be used with the ANSI C strftime function.</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">●</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkRadioButton" id="radio_print_gtk">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Use native GTK printing</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">False</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
<property name="group">radio_print_external</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label204">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;i&gt;Notice: Native GTK printing is only available if Geany was built against GTK 2.10 (or above) &lt;b&gt;and&lt;/b&gt; Geany is running with GTK 2.10 (or above).&lt;/i&gt;</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">True</property>
<property name="selectable">False</property>
<property name="xalign">0.0500000007451</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">5</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="tab_expand">False</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label201">
<property name="visible">True</property>
<property name="label" translatable="yes">Printing</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="type">tab</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">6</property>

View File

@ -26,6 +26,7 @@ SRCS = \
notebook.c notebook.h \
plugins.c plugins.h \
prefs.c prefs.h \
printing.c printing.h \
project.c project.h \
sciwrappers.c sciwrappers.h \
search.c search.h \

View File

@ -61,7 +61,7 @@
#include "tools.h"
#include "project.h"
#include "navqueue.h"
//#include "printing.h"
#include "printing.h"
#include "geanyobject.h"
@ -298,6 +298,12 @@ on_file1_activate (GtkMenuItem *menuitem,
{
gtk_widget_set_sensitive(ui_widgets.recent_files_menuitem,
g_queue_get_length(ui_prefs.recent_queue) > 0);
#if GTK_CHECK_VERSION(2, 10, 0)
// hide Page setup when GTK printing is not used
// (on GTK < 2.10 the menu item is hidden completely)
ui_widget_show_hide(ui_widgets.print_page_setup,
printing_prefs.use_gtk_printing || gtk_check_version(2, 10, 0) != NULL);
#endif
}
@ -1618,8 +1624,7 @@ on_print1_activate (GtkMenuItem *menuitem,
gint idx = document_get_cur_idx();
if (! DOC_IDX_VALID(idx))
return;
//printing_print_doc(idx);
document_print(idx);
printing_print_doc(idx);
}
@ -2131,3 +2136,13 @@ on_strip_trailing_spaces1_activate (GtkMenuItem *menuitem,
document_strip_trailing_spaces(idx);
}
void
on_page_setup1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
#if GTK_CHECK_VERSION(2, 10, 0)
printing_page_setup_gtk();
#endif
}

View File

@ -591,3 +591,7 @@ on_spaces1_activate (GtkMenuItem *menuitem,
void
on_strip_trailing_spaces1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_page_setup1_activate (GtkMenuItem *menuitem,
gpointer user_data);

View File

@ -1995,49 +1995,6 @@ void document_set_indicator(gint idx, gint line)
}
/* simple file print */
void document_print(gint idx)
{
gchar *cmdline;
if (! DOC_IDX_VALID(idx) || doc_list[idx].file_name == NULL)
return;
cmdline = g_strdup(prefs.tools_print_cmd);
cmdline = utils_str_replace(cmdline, "%f", doc_list[idx].file_name);
if (dialogs_show_question(
_("The file \"%s\" will be printed with the following command:\n\n%s"),
doc_list[idx].file_name, cmdline))
{
GError *error = NULL;
#ifdef G_OS_WIN32
gchar *tmp_cmdline = cmdline;
#else
// /bin/sh -c emulates the system() call and makes complex commands possible
// but only needed on non-win32 systems due to the lack of win32's shell capabilities
gchar *tmp_cmdline = g_strconcat("/bin/sh -c \"", cmdline, "\"", NULL);
#endif
if (! g_spawn_command_line_async(tmp_cmdline, &error))
{
dialogs_show_msgbox(GTK_MESSAGE_ERROR, _("Printing of \"%s\" failed (return code: %s)."),
doc_list[idx].file_name, error->message);
g_error_free(error);
}
else
{
ui_set_statusbar(TRUE, _("File %s printed."), doc_list[idx].file_name);
}
#ifndef G_OS_WIN32
g_free(tmp_cmdline);
#endif
}
g_free(cmdline);
}
void document_replace_tabs(gint idx)
{
gint search_pos, pos_in_line, current_tab_true_length;

View File

@ -186,9 +186,6 @@ void document_set_indicator(gint idx, gint line);
void document_clear_indicators(gint idx);
/* simple file print */
void document_print(gint idx);
void document_replace_tabs(gint idx);
void document_strip_line_trailing_spaces(gint idx, gint line);

View File

@ -37,7 +37,7 @@ create_window1 (void)
GtkWidget *file1_menu;
GtkWidget *menu_new1;
GtkWidget *menu_new_with_template1;
GtkWidget *image2282;
GtkWidget *image2299;
GtkWidget *menu_new_with_template1_menu;
GtkWidget *invisible2;
GtkWidget *separator12;
@ -48,11 +48,11 @@ create_window1 (void)
GtkWidget *menu_save1;
GtkWidget *menu_save_as1;
GtkWidget *menu_save_all1;
GtkWidget *image2283;
GtkWidget *image2300;
GtkWidget *menu_reload1;
GtkWidget *image2284;
GtkWidget *image2301;
GtkWidget *menu_reload_as1;
GtkWidget *image2285;
GtkWidget *image2302;
GtkWidget *menu_reload_as1_menu;
GtkWidget *invisible7;
GtkWidget *separator21;
@ -60,11 +60,12 @@ create_window1 (void)
GtkWidget *separator39;
GtkWidget *preferences2;
GtkWidget *separator24;
GtkWidget *page_setup1;
GtkWidget *print1;
GtkWidget *separator14;
GtkWidget *menu_close1;
GtkWidget *menu_close_all1;
GtkWidget *image2286;
GtkWidget *image2303;
GtkWidget *menu_separatormenuitem1;
GtkWidget *menu_quit1;
GtkWidget *edit1;
@ -89,16 +90,16 @@ create_window1 (void)
GtkWidget *menu_duplicate_line1;
GtkWidget *separator29;
GtkWidget *menu_increase_indent1;
GtkWidget *image2287;
GtkWidget *image2304;
GtkWidget *menu_decrease_indent1;
GtkWidget *image2288;
GtkWidget *image2305;
GtkWidget *separator37;
GtkWidget *send_selection_to2;
GtkWidget *send_selection_to2_menu;
GtkWidget *invisible13;
GtkWidget *separator18;
GtkWidget *add_comments1;
GtkWidget *image2289;
GtkWidget *image2306;
GtkWidget *add_comments1_menu;
GtkWidget *menu_add_changelog_entry1;
GtkWidget *insert_file_header1;
@ -107,11 +108,11 @@ create_window1 (void)
GtkWidget *insert_gpl_notice2;
GtkWidget *insert_bsd_license_notice2;
GtkWidget *insert_date1;
GtkWidget *image2290;
GtkWidget *image2307;
GtkWidget *insert_date1_menu;
GtkWidget *invisible8;
GtkWidget *insert_include2;
GtkWidget *image2291;
GtkWidget *image2308;
GtkWidget *insert_include2_menu;
GtkWidget *invisible4;
GtkWidget *separator9;
@ -123,7 +124,7 @@ create_window1 (void)
GtkWidget *find_previous1;
GtkWidget *find_in_files1;
GtkWidget *replace1;
GtkWidget *image2292;
GtkWidget *image2309;
GtkWidget *separator33;
GtkWidget *find_nextsel1;
GtkWidget *find_prevsel1;
@ -131,11 +132,11 @@ create_window1 (void)
GtkWidget *next_message1;
GtkWidget *separator32;
GtkWidget *go_to_line1;
GtkWidget *image2293;
GtkWidget *image2310;
GtkWidget *menu_view1;
GtkWidget *menu_view1_menu;
GtkWidget *menu_change_font1;
GtkWidget *image2294;
GtkWidget *image2311;
GtkWidget *menu_separator4;
GtkWidget *menu_toggle_all_additional_widgets1;
GtkWidget *menu_fullscreen1;
@ -185,23 +186,23 @@ create_window1 (void)
GtkWidget *menu_project1;
GtkWidget *menu_project1_menu;
GtkWidget *project_new1;
GtkWidget *image2295;
GtkWidget *image2312;
GtkWidget *project_open1;
GtkWidget *image2296;
GtkWidget *image2313;
GtkWidget *project_close1;
GtkWidget *image2297;
GtkWidget *image2314;
GtkWidget *separator34;
GtkWidget *project_properties1;
GtkWidget *menu_build1;
GtkWidget *tools1;
GtkWidget *tools1_menu;
GtkWidget *menu_choose_color1;
GtkWidget *image2298;
GtkWidget *image2315;
GtkWidget *menu_count_words1;
GtkWidget *menu_help1;
GtkWidget *menu_help1_menu;
GtkWidget *help1;
GtkWidget *image2299;
GtkWidget *image2316;
GtkWidget *keyboard_shortcuts1;
GtkWidget *website1;
GtkWidget *separator16;
@ -301,9 +302,9 @@ create_window1 (void)
gtk_widget_show (menu_new_with_template1);
gtk_container_add (GTK_CONTAINER (file1_menu), menu_new_with_template1);
image2282 = gtk_image_new_from_stock ("gtk-new", GTK_ICON_SIZE_MENU);
gtk_widget_show (image2282);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_new_with_template1), image2282);
image2299 = gtk_image_new_from_stock ("gtk-new", GTK_ICON_SIZE_MENU);
gtk_widget_show (image2299);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_new_with_template1), image2299);
menu_new_with_template1_menu = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_new_with_template1), menu_new_with_template1_menu);
@ -346,25 +347,25 @@ create_window1 (void)
gtk_container_add (GTK_CONTAINER (file1_menu), menu_save_all1);
gtk_tooltips_set_tip (tooltips, menu_save_all1, _("Saves all open files"), NULL);
image2283 = gtk_image_new_from_stock ("gtk-save", GTK_ICON_SIZE_MENU);
gtk_widget_show (image2283);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_save_all1), image2283);
image2300 = gtk_image_new_from_stock ("gtk-save", GTK_ICON_SIZE_MENU);
gtk_widget_show (image2300);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_save_all1), image2300);
menu_reload1 = gtk_image_menu_item_new_with_mnemonic (_("_Reload"));
gtk_widget_show (menu_reload1);
gtk_container_add (GTK_CONTAINER (file1_menu), menu_reload1);
image2284 = gtk_image_new_from_stock ("gtk-revert-to-saved", GTK_ICON_SIZE_MENU);
gtk_widget_show (image2284);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_reload1), image2284);
image2301 = gtk_image_new_from_stock ("gtk-revert-to-saved", GTK_ICON_SIZE_MENU);
gtk_widget_show (image2301);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_reload1), image2301);
menu_reload_as1 = gtk_image_menu_item_new_with_mnemonic (_("R_eload As"));
gtk_widget_show (menu_reload_as1);
gtk_container_add (GTK_CONTAINER (file1_menu), menu_reload_as1);
image2285 = gtk_image_new_from_stock ("gtk-revert-to-saved", GTK_ICON_SIZE_MENU);
gtk_widget_show (image2285);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_reload_as1), image2285);
image2302 = gtk_image_new_from_stock ("gtk-revert-to-saved", GTK_ICON_SIZE_MENU);
gtk_widget_show (image2302);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_reload_as1), image2302);
menu_reload_as1_menu = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_reload_as1), menu_reload_as1_menu);
@ -396,6 +397,10 @@ create_window1 (void)
gtk_container_add (GTK_CONTAINER (file1_menu), separator24);
gtk_widget_set_sensitive (separator24, FALSE);
page_setup1 = gtk_menu_item_new_with_mnemonic (_("Page set_up"));
gtk_widget_show (page_setup1);
gtk_container_add (GTK_CONTAINER (file1_menu), page_setup1);
print1 = gtk_image_menu_item_new_from_stock ("gtk-print", accel_group);
gtk_widget_show (print1);
gtk_container_add (GTK_CONTAINER (file1_menu), print1);
@ -415,9 +420,9 @@ create_window1 (void)
gtk_container_add (GTK_CONTAINER (file1_menu), menu_close_all1);
gtk_tooltips_set_tip (tooltips, menu_close_all1, _("Closes all open files"), NULL);
image2286 = gtk_image_new_from_stock ("gtk-close", GTK_ICON_SIZE_MENU);
gtk_widget_show (image2286);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_close_all1), image2286);
image2303 = gtk_image_new_from_stock ("gtk-close", GTK_ICON_SIZE_MENU);
gtk_widget_show (image2303);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_close_all1), image2303);
menu_separatormenuitem1 = gtk_separator_menu_item_new ();
gtk_widget_show (menu_separatormenuitem1);
@ -521,17 +526,17 @@ create_window1 (void)
gtk_widget_show (menu_increase_indent1);
gtk_container_add (GTK_CONTAINER (menu_format1_menu), menu_increase_indent1);
image2287 = gtk_image_new_from_stock ("gtk-indent", GTK_ICON_SIZE_MENU);
gtk_widget_show (image2287);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_increase_indent1), image2287);
image2304 = gtk_image_new_from_stock ("gtk-indent", GTK_ICON_SIZE_MENU);
gtk_widget_show (image2304);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_increase_indent1), image2304);
menu_decrease_indent1 = gtk_image_menu_item_new_with_mnemonic (_("_Decrease Indent"));
gtk_widget_show (menu_decrease_indent1);
gtk_container_add (GTK_CONTAINER (menu_format1_menu), menu_decrease_indent1);
image2288 = gtk_image_new_from_stock ("gtk-unindent", GTK_ICON_SIZE_MENU);
gtk_widget_show (image2288);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_decrease_indent1), image2288);
image2305 = gtk_image_new_from_stock ("gtk-unindent", GTK_ICON_SIZE_MENU);
gtk_widget_show (image2305);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_decrease_indent1), image2305);
separator37 = gtk_separator_menu_item_new ();
gtk_widget_show (separator37);
@ -557,9 +562,9 @@ create_window1 (void)
gtk_widget_show (add_comments1);
gtk_container_add (GTK_CONTAINER (edit1_menu), add_comments1);
image2289 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU);
gtk_widget_show (image2289);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (add_comments1), image2289);
image2306 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU);
gtk_widget_show (image2306);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (add_comments1), image2306);
add_comments1_menu = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (add_comments1), add_comments1_menu);
@ -598,9 +603,9 @@ create_window1 (void)
gtk_widget_show (insert_date1);
gtk_container_add (GTK_CONTAINER (edit1_menu), insert_date1);
image2290 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU);
gtk_widget_show (image2290);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (insert_date1), image2290);
image2307 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU);
gtk_widget_show (image2307);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (insert_date1), image2307);
insert_date1_menu = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (insert_date1), insert_date1_menu);
@ -612,9 +617,9 @@ create_window1 (void)
gtk_widget_show (insert_include2);
gtk_container_add (GTK_CONTAINER (edit1_menu), insert_include2);
image2291 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU);
gtk_widget_show (image2291);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (insert_include2), image2291);
image2308 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_MENU);
gtk_widget_show (image2308);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (insert_include2), image2308);
insert_include2_menu = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (insert_include2), insert_include2_menu);
@ -658,9 +663,9 @@ create_window1 (void)
gtk_widget_show (replace1);
gtk_container_add (GTK_CONTAINER (search1_menu), replace1);
image2292 = gtk_image_new_from_stock ("gtk-find-and-replace", GTK_ICON_SIZE_MENU);
gtk_widget_show (image2292);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (replace1), image2292);
image2309 = gtk_image_new_from_stock ("gtk-find-and-replace", GTK_ICON_SIZE_MENU);
gtk_widget_show (image2309);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (replace1), image2309);
separator33 = gtk_separator_menu_item_new ();
gtk_widget_show (separator33);
@ -693,9 +698,9 @@ create_window1 (void)
gtk_widget_show (go_to_line1);
gtk_container_add (GTK_CONTAINER (search1_menu), go_to_line1);
image2293 = gtk_image_new_from_stock ("gtk-jump-to", GTK_ICON_SIZE_MENU);
gtk_widget_show (image2293);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (go_to_line1), image2293);
image2310 = gtk_image_new_from_stock ("gtk-jump-to", GTK_ICON_SIZE_MENU);
gtk_widget_show (image2310);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (go_to_line1), image2310);
menu_view1 = gtk_menu_item_new_with_mnemonic (_("_View"));
gtk_widget_show (menu_view1);
@ -709,9 +714,9 @@ create_window1 (void)
gtk_container_add (GTK_CONTAINER (menu_view1_menu), menu_change_font1);
gtk_tooltips_set_tip (tooltips, menu_change_font1, _("Change the default font"), NULL);
image2294 = gtk_image_new_from_stock ("gtk-select-font", GTK_ICON_SIZE_MENU);
gtk_widget_show (image2294);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_change_font1), image2294);
image2311 = gtk_image_new_from_stock ("gtk-select-font", GTK_ICON_SIZE_MENU);
gtk_widget_show (image2311);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_change_font1), image2311);
menu_separator4 = gtk_separator_menu_item_new ();
gtk_widget_show (menu_separator4);
@ -927,25 +932,25 @@ create_window1 (void)
gtk_widget_show (project_new1);
gtk_container_add (GTK_CONTAINER (menu_project1_menu), project_new1);
image2295 = gtk_image_new_from_stock ("gtk-new", GTK_ICON_SIZE_MENU);
gtk_widget_show (image2295);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (project_new1), image2295);
image2312 = gtk_image_new_from_stock ("gtk-new", GTK_ICON_SIZE_MENU);
gtk_widget_show (image2312);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (project_new1), image2312);
project_open1 = gtk_image_menu_item_new_with_mnemonic (_("_Open"));
gtk_widget_show (project_open1);
gtk_container_add (GTK_CONTAINER (menu_project1_menu), project_open1);
image2296 = gtk_image_new_from_stock ("gtk-open", GTK_ICON_SIZE_MENU);
gtk_widget_show (image2296);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (project_open1), image2296);
image2313 = gtk_image_new_from_stock ("gtk-open", GTK_ICON_SIZE_MENU);
gtk_widget_show (image2313);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (project_open1), image2313);
project_close1 = gtk_image_menu_item_new_with_mnemonic (_("_Close"));
gtk_widget_show (project_close1);
gtk_container_add (GTK_CONTAINER (menu_project1_menu), project_close1);
image2297 = gtk_image_new_from_stock ("gtk-close", GTK_ICON_SIZE_MENU);
gtk_widget_show (image2297);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (project_close1), image2297);
image2314 = gtk_image_new_from_stock ("gtk-close", GTK_ICON_SIZE_MENU);
gtk_widget_show (image2314);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (project_close1), image2314);
separator34 = gtk_separator_menu_item_new ();
gtk_widget_show (separator34);
@ -972,9 +977,9 @@ create_window1 (void)
gtk_container_add (GTK_CONTAINER (tools1_menu), menu_choose_color1);
gtk_tooltips_set_tip (tooltips, menu_choose_color1, _("Open a color chooser dialog, to interactively pick colors from a palette."), NULL);
image2298 = gtk_image_new_from_stock ("gtk-select-color", GTK_ICON_SIZE_MENU);
gtk_widget_show (image2298);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_choose_color1), image2298);
image2315 = gtk_image_new_from_stock ("gtk-select-color", GTK_ICON_SIZE_MENU);
gtk_widget_show (image2315);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_choose_color1), image2315);
menu_count_words1 = gtk_menu_item_new_with_mnemonic (_("_Word Count"));
gtk_widget_show (menu_count_words1);
@ -992,9 +997,9 @@ create_window1 (void)
gtk_widget_show (help1);
gtk_container_add (GTK_CONTAINER (menu_help1_menu), help1);
image2299 = gtk_image_new_from_stock ("gtk-help", GTK_ICON_SIZE_MENU);
gtk_widget_show (image2299);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (help1), image2299);
image2316 = gtk_image_new_from_stock ("gtk-help", GTK_ICON_SIZE_MENU);
gtk_widget_show (image2316);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (help1), image2316);
keyboard_shortcuts1 = gtk_menu_item_new_with_mnemonic (_("_Keyboard Shortcuts"));
gtk_widget_show (keyboard_shortcuts1);
@ -1337,6 +1342,9 @@ create_window1 (void)
g_signal_connect ((gpointer) preferences2, "activate",
G_CALLBACK (on_file_properties_activate),
NULL);
g_signal_connect ((gpointer) page_setup1, "activate",
G_CALLBACK (on_page_setup1_activate),
NULL);
g_signal_connect ((gpointer) print1, "activate",
G_CALLBACK (on_print1_activate),
NULL);
@ -1647,7 +1655,7 @@ create_window1 (void)
GLADE_HOOKUP_OBJECT (window1, file1_menu, "file1_menu");
GLADE_HOOKUP_OBJECT (window1, menu_new1, "menu_new1");
GLADE_HOOKUP_OBJECT (window1, menu_new_with_template1, "menu_new_with_template1");
GLADE_HOOKUP_OBJECT (window1, image2282, "image2282");
GLADE_HOOKUP_OBJECT (window1, image2299, "image2299");
GLADE_HOOKUP_OBJECT (window1, menu_new_with_template1_menu, "menu_new_with_template1_menu");
GLADE_HOOKUP_OBJECT (window1, invisible2, "invisible2");
GLADE_HOOKUP_OBJECT (window1, separator12, "separator12");
@ -1658,11 +1666,11 @@ create_window1 (void)
GLADE_HOOKUP_OBJECT (window1, menu_save1, "menu_save1");
GLADE_HOOKUP_OBJECT (window1, menu_save_as1, "menu_save_as1");
GLADE_HOOKUP_OBJECT (window1, menu_save_all1, "menu_save_all1");
GLADE_HOOKUP_OBJECT (window1, image2283, "image2283");
GLADE_HOOKUP_OBJECT (window1, image2300, "image2300");
GLADE_HOOKUP_OBJECT (window1, menu_reload1, "menu_reload1");
GLADE_HOOKUP_OBJECT (window1, image2284, "image2284");
GLADE_HOOKUP_OBJECT (window1, image2301, "image2301");
GLADE_HOOKUP_OBJECT (window1, menu_reload_as1, "menu_reload_as1");
GLADE_HOOKUP_OBJECT (window1, image2285, "image2285");
GLADE_HOOKUP_OBJECT (window1, image2302, "image2302");
GLADE_HOOKUP_OBJECT (window1, menu_reload_as1_menu, "menu_reload_as1_menu");
GLADE_HOOKUP_OBJECT (window1, invisible7, "invisible7");
GLADE_HOOKUP_OBJECT (window1, separator21, "separator21");
@ -1670,11 +1678,12 @@ create_window1 (void)
GLADE_HOOKUP_OBJECT (window1, separator39, "separator39");
GLADE_HOOKUP_OBJECT (window1, preferences2, "preferences2");
GLADE_HOOKUP_OBJECT (window1, separator24, "separator24");
GLADE_HOOKUP_OBJECT (window1, page_setup1, "page_setup1");
GLADE_HOOKUP_OBJECT (window1, print1, "print1");
GLADE_HOOKUP_OBJECT (window1, separator14, "separator14");
GLADE_HOOKUP_OBJECT (window1, menu_close1, "menu_close1");
GLADE_HOOKUP_OBJECT (window1, menu_close_all1, "menu_close_all1");
GLADE_HOOKUP_OBJECT (window1, image2286, "image2286");
GLADE_HOOKUP_OBJECT (window1, image2303, "image2303");
GLADE_HOOKUP_OBJECT (window1, menu_separatormenuitem1, "menu_separatormenuitem1");
GLADE_HOOKUP_OBJECT (window1, menu_quit1, "menu_quit1");
GLADE_HOOKUP_OBJECT (window1, edit1, "edit1");
@ -1699,16 +1708,16 @@ create_window1 (void)
GLADE_HOOKUP_OBJECT (window1, menu_duplicate_line1, "menu_duplicate_line1");
GLADE_HOOKUP_OBJECT (window1, separator29, "separator29");
GLADE_HOOKUP_OBJECT (window1, menu_increase_indent1, "menu_increase_indent1");
GLADE_HOOKUP_OBJECT (window1, image2287, "image2287");
GLADE_HOOKUP_OBJECT (window1, image2304, "image2304");
GLADE_HOOKUP_OBJECT (window1, menu_decrease_indent1, "menu_decrease_indent1");
GLADE_HOOKUP_OBJECT (window1, image2288, "image2288");
GLADE_HOOKUP_OBJECT (window1, image2305, "image2305");
GLADE_HOOKUP_OBJECT (window1, separator37, "separator37");
GLADE_HOOKUP_OBJECT (window1, send_selection_to2, "send_selection_to2");
GLADE_HOOKUP_OBJECT (window1, send_selection_to2_menu, "send_selection_to2_menu");
GLADE_HOOKUP_OBJECT (window1, invisible13, "invisible13");
GLADE_HOOKUP_OBJECT (window1, separator18, "separator18");
GLADE_HOOKUP_OBJECT (window1, add_comments1, "add_comments1");
GLADE_HOOKUP_OBJECT (window1, image2289, "image2289");
GLADE_HOOKUP_OBJECT (window1, image2306, "image2306");
GLADE_HOOKUP_OBJECT (window1, add_comments1_menu, "add_comments1_menu");
GLADE_HOOKUP_OBJECT (window1, menu_add_changelog_entry1, "menu_add_changelog_entry1");
GLADE_HOOKUP_OBJECT (window1, insert_file_header1, "insert_file_header1");
@ -1717,11 +1726,11 @@ create_window1 (void)
GLADE_HOOKUP_OBJECT (window1, insert_gpl_notice2, "insert_gpl_notice2");
GLADE_HOOKUP_OBJECT (window1, insert_bsd_license_notice2, "insert_bsd_license_notice2");
GLADE_HOOKUP_OBJECT (window1, insert_date1, "insert_date1");
GLADE_HOOKUP_OBJECT (window1, image2290, "image2290");
GLADE_HOOKUP_OBJECT (window1, image2307, "image2307");
GLADE_HOOKUP_OBJECT (window1, insert_date1_menu, "insert_date1_menu");
GLADE_HOOKUP_OBJECT (window1, invisible8, "invisible8");
GLADE_HOOKUP_OBJECT (window1, insert_include2, "insert_include2");
GLADE_HOOKUP_OBJECT (window1, image2291, "image2291");
GLADE_HOOKUP_OBJECT (window1, image2308, "image2308");
GLADE_HOOKUP_OBJECT (window1, insert_include2_menu, "insert_include2_menu");
GLADE_HOOKUP_OBJECT (window1, invisible4, "invisible4");
GLADE_HOOKUP_OBJECT (window1, separator9, "separator9");
@ -1733,7 +1742,7 @@ create_window1 (void)
GLADE_HOOKUP_OBJECT (window1, find_previous1, "find_previous1");
GLADE_HOOKUP_OBJECT (window1, find_in_files1, "find_in_files1");
GLADE_HOOKUP_OBJECT (window1, replace1, "replace1");
GLADE_HOOKUP_OBJECT (window1, image2292, "image2292");
GLADE_HOOKUP_OBJECT (window1, image2309, "image2309");
GLADE_HOOKUP_OBJECT (window1, separator33, "separator33");
GLADE_HOOKUP_OBJECT (window1, find_nextsel1, "find_nextsel1");
GLADE_HOOKUP_OBJECT (window1, find_prevsel1, "find_prevsel1");
@ -1741,11 +1750,11 @@ create_window1 (void)
GLADE_HOOKUP_OBJECT (window1, next_message1, "next_message1");
GLADE_HOOKUP_OBJECT (window1, separator32, "separator32");
GLADE_HOOKUP_OBJECT (window1, go_to_line1, "go_to_line1");
GLADE_HOOKUP_OBJECT (window1, image2293, "image2293");
GLADE_HOOKUP_OBJECT (window1, image2310, "image2310");
GLADE_HOOKUP_OBJECT (window1, menu_view1, "menu_view1");
GLADE_HOOKUP_OBJECT (window1, menu_view1_menu, "menu_view1_menu");
GLADE_HOOKUP_OBJECT (window1, menu_change_font1, "menu_change_font1");
GLADE_HOOKUP_OBJECT (window1, image2294, "image2294");
GLADE_HOOKUP_OBJECT (window1, image2311, "image2311");
GLADE_HOOKUP_OBJECT (window1, menu_separator4, "menu_separator4");
GLADE_HOOKUP_OBJECT (window1, menu_toggle_all_additional_widgets1, "menu_toggle_all_additional_widgets1");
GLADE_HOOKUP_OBJECT (window1, menu_fullscreen1, "menu_fullscreen1");
@ -1793,23 +1802,23 @@ create_window1 (void)
GLADE_HOOKUP_OBJECT (window1, menu_project1, "menu_project1");
GLADE_HOOKUP_OBJECT (window1, menu_project1_menu, "menu_project1_menu");
GLADE_HOOKUP_OBJECT (window1, project_new1, "project_new1");
GLADE_HOOKUP_OBJECT (window1, image2295, "image2295");
GLADE_HOOKUP_OBJECT (window1, image2312, "image2312");
GLADE_HOOKUP_OBJECT (window1, project_open1, "project_open1");
GLADE_HOOKUP_OBJECT (window1, image2296, "image2296");
GLADE_HOOKUP_OBJECT (window1, image2313, "image2313");
GLADE_HOOKUP_OBJECT (window1, project_close1, "project_close1");
GLADE_HOOKUP_OBJECT (window1, image2297, "image2297");
GLADE_HOOKUP_OBJECT (window1, image2314, "image2314");
GLADE_HOOKUP_OBJECT (window1, separator34, "separator34");
GLADE_HOOKUP_OBJECT (window1, project_properties1, "project_properties1");
GLADE_HOOKUP_OBJECT (window1, menu_build1, "menu_build1");
GLADE_HOOKUP_OBJECT (window1, tools1, "tools1");
GLADE_HOOKUP_OBJECT (window1, tools1_menu, "tools1_menu");
GLADE_HOOKUP_OBJECT (window1, menu_choose_color1, "menu_choose_color1");
GLADE_HOOKUP_OBJECT (window1, image2298, "image2298");
GLADE_HOOKUP_OBJECT (window1, image2315, "image2315");
GLADE_HOOKUP_OBJECT (window1, menu_count_words1, "menu_count_words1");
GLADE_HOOKUP_OBJECT (window1, menu_help1, "menu_help1");
GLADE_HOOKUP_OBJECT (window1, menu_help1_menu, "menu_help1_menu");
GLADE_HOOKUP_OBJECT (window1, help1, "help1");
GLADE_HOOKUP_OBJECT (window1, image2299, "image2299");
GLADE_HOOKUP_OBJECT (window1, image2316, "image2316");
GLADE_HOOKUP_OBJECT (window1, keyboard_shortcuts1, "keyboard_shortcuts1");
GLADE_HOOKUP_OBJECT (window1, website1, "website1");
GLADE_HOOKUP_OBJECT (window1, separator16, "separator16");
@ -2659,12 +2668,8 @@ create_prefs_dialog (void)
GtkWidget *frame26;
GtkWidget *alignment29;
GtkWidget *table12;
GtkWidget *entry_print;
GtkWidget *button_print;
GtkWidget *image763;
GtkWidget *label154;
GtkWidget *entry_contextaction;
GtkWidget *label189;
GtkWidget *entry_contextaction;
GtkWidget *button_contextaction;
GtkWidget *image1919;
GtkWidget *label193;
@ -2697,6 +2702,32 @@ create_prefs_dialog (void)
GtkWidget *button2;
GtkWidget *label181;
GtkWidget *label151;
GtkWidget *vbox27;
GtkWidget *frame32;
GtkWidget *alignment35;
GtkWidget *hbox9;
GtkWidget *label202;
GtkWidget *entry_print_external_cmd;
GtkWidget *button_print_external_cmd;
GtkWidget *image763;
GtkWidget *radio_print_external;
GSList *radio_print_external_group = NULL;
GtkWidget *frame31;
GtkWidget *alignment34;
GtkWidget *vbox29;
GtkWidget *check_print_linenumbers;
GtkWidget *check_print_pagenumbers;
GtkWidget *check_print_pageheader;
GtkWidget *frame33;
GtkWidget *alignment36;
GtkWidget *vbox30;
GtkWidget *check_print_basename;
GtkWidget *hbox10;
GtkWidget *label203;
GtkWidget *entry_print_dateformat;
GtkWidget *radio_print_gtk;
GtkWidget *label204;
GtkWidget *label201;
GtkWidget *dialog_action_area3;
GtkWidget *button3;
GtkWidget *button4;
@ -3995,47 +4026,23 @@ create_prefs_dialog (void)
gtk_table_set_row_spacings (GTK_TABLE (table12), 3);
gtk_table_set_col_spacings (GTK_TABLE (table12), 6);
entry_print = gtk_entry_new ();
gtk_widget_show (entry_print);
gtk_table_attach (GTK_TABLE (table12), entry_print, 1, 2, 0, 1,
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_tooltips_set_tip (tooltips, entry_print, _("Path to the command for printing files (use %f for the filename)."), NULL);
button_print = gtk_button_new ();
gtk_widget_show (button_print);
gtk_table_attach (GTK_TABLE (table12), button_print, 2, 3, 0, 1,
label189 = gtk_label_new (_("Context action:"));
gtk_widget_show (label189);
gtk_table_attach (GTK_TABLE (table12), label189, 0, 1, 0, 1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
image763 = gtk_image_new_from_stock ("gtk-open", GTK_ICON_SIZE_BUTTON);
gtk_widget_show (image763);
gtk_container_add (GTK_CONTAINER (button_print), image763);
label154 = gtk_label_new (_("Print:"));
gtk_widget_show (label154);
gtk_table_attach (GTK_TABLE (table12), label154, 0, 1, 0, 1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_misc_set_alignment (GTK_MISC (label154), 0, 0.5);
entry_contextaction = gtk_entry_new ();
gtk_widget_show (entry_contextaction);
gtk_table_attach (GTK_TABLE (table12), entry_contextaction, 1, 2, 1, 2,
gtk_table_attach (GTK_TABLE (table12), entry_contextaction, 1, 2, 0, 1,
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_tooltips_set_tip (tooltips, entry_contextaction, _("Context action command. The currently selected word can be used with %s. It can appear anywhere in the given command and will be replaced before execution."), NULL);
gtk_entry_set_invisible_char (GTK_ENTRY (entry_contextaction), 9679);
label189 = gtk_label_new (_("Context action:"));
gtk_widget_show (label189);
gtk_table_attach (GTK_TABLE (table12), label189, 0, 1, 1, 2,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
button_contextaction = gtk_button_new ();
gtk_widget_show (button_contextaction);
gtk_table_attach (GTK_TABLE (table12), button_contextaction, 2, 3, 1, 2,
gtk_table_attach (GTK_TABLE (table12), button_contextaction, 2, 3, 0, 1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
@ -4215,6 +4222,133 @@ create_prefs_dialog (void)
gtk_widget_show (label151);
gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook2), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook2), 8), label151);
vbox27 = gtk_vbox_new (FALSE, 0);
gtk_widget_show (vbox27);
gtk_container_add (GTK_CONTAINER (notebook2), vbox27);
frame32 = gtk_frame_new (NULL);
gtk_widget_show (frame32);
gtk_box_pack_start (GTK_BOX (vbox27), frame32, FALSE, FALSE, 0);
gtk_frame_set_shadow_type (GTK_FRAME (frame32), GTK_SHADOW_NONE);
alignment35 = gtk_alignment_new (0.5, 0.5, 1, 1);
gtk_widget_show (alignment35);
gtk_container_add (GTK_CONTAINER (frame32), alignment35);
gtk_alignment_set_padding (GTK_ALIGNMENT (alignment35), 0, 0, 12, 0);
hbox9 = gtk_hbox_new (FALSE, 5);
gtk_widget_show (hbox9);
gtk_container_add (GTK_CONTAINER (alignment35), hbox9);
label202 = gtk_label_new (_("Command:"));
gtk_widget_show (label202);
gtk_box_pack_start (GTK_BOX (hbox9), label202, FALSE, FALSE, 0);
entry_print_external_cmd = gtk_entry_new ();
gtk_widget_show (entry_print_external_cmd);
gtk_box_pack_start (GTK_BOX (hbox9), entry_print_external_cmd, TRUE, TRUE, 0);
gtk_tooltips_set_tip (tooltips, entry_print_external_cmd, _("Path to the command for printing files (use %f for the filename)."), NULL);
button_print_external_cmd = gtk_button_new ();
gtk_widget_show (button_print_external_cmd);
gtk_box_pack_start (GTK_BOX (hbox9), button_print_external_cmd, FALSE, FALSE, 0);
image763 = gtk_image_new_from_stock ("gtk-open", GTK_ICON_SIZE_BUTTON);
gtk_widget_show (image763);
gtk_container_add (GTK_CONTAINER (button_print_external_cmd), image763);
radio_print_external = gtk_radio_button_new_with_mnemonic (NULL, _("Use an external command for printing"));
gtk_widget_show (radio_print_external);
gtk_frame_set_label_widget (GTK_FRAME (frame32), radio_print_external);
gtk_button_set_focus_on_click (GTK_BUTTON (radio_print_external), FALSE);
gtk_radio_button_set_group (GTK_RADIO_BUTTON (radio_print_external), radio_print_external_group);
radio_print_external_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio_print_external));
frame31 = gtk_frame_new (NULL);
gtk_widget_show (frame31);
gtk_box_pack_start (GTK_BOX (vbox27), frame31, FALSE, TRUE, 0);
gtk_frame_set_shadow_type (GTK_FRAME (frame31), GTK_SHADOW_NONE);
alignment34 = gtk_alignment_new (0.5, 0.5, 1, 1);
gtk_widget_show (alignment34);
gtk_container_add (GTK_CONTAINER (frame31), alignment34);
gtk_alignment_set_padding (GTK_ALIGNMENT (alignment34), 0, 0, 12, 0);
vbox29 = gtk_vbox_new (FALSE, 0);
gtk_widget_show (vbox29);
gtk_container_add (GTK_CONTAINER (alignment34), vbox29);
check_print_linenumbers = gtk_check_button_new_with_mnemonic (_("Print line numbers"));
gtk_widget_show (check_print_linenumbers);
gtk_box_pack_start (GTK_BOX (vbox29), check_print_linenumbers, FALSE, FALSE, 0);
gtk_tooltips_set_tip (tooltips, check_print_linenumbers, _("Add line numbers to the printed page."), NULL);
gtk_button_set_focus_on_click (GTK_BUTTON (check_print_linenumbers), FALSE);
check_print_pagenumbers = gtk_check_button_new_with_mnemonic (_("Print page numbers"));
gtk_widget_show (check_print_pagenumbers);
gtk_box_pack_start (GTK_BOX (vbox29), check_print_pagenumbers, FALSE, FALSE, 0);
gtk_tooltips_set_tip (tooltips, check_print_pagenumbers, _("Add page numbers at the bottom of each page. It takes 2 lines of the page."), NULL);
gtk_button_set_focus_on_click (GTK_BUTTON (check_print_pagenumbers), FALSE);
check_print_pageheader = gtk_check_button_new_with_mnemonic (_("Print page header"));
gtk_widget_show (check_print_pageheader);
gtk_box_pack_start (GTK_BOX (vbox29), check_print_pageheader, FALSE, FALSE, 0);
gtk_tooltips_set_tip (tooltips, check_print_pageheader, _("Adds a little header to every page containing the page number, the filename and the current date(see below). It takes 3 lines of the page."), NULL);
gtk_button_set_focus_on_click (GTK_BUTTON (check_print_pageheader), FALSE);
frame33 = gtk_frame_new (NULL);
gtk_widget_show (frame33);
gtk_box_pack_start (GTK_BOX (vbox29), frame33, TRUE, TRUE, 0);
gtk_frame_set_label_align (GTK_FRAME (frame33), 0, 0);
gtk_frame_set_shadow_type (GTK_FRAME (frame33), GTK_SHADOW_NONE);
alignment36 = gtk_alignment_new (0, 0.5, 1, 1);
gtk_widget_show (alignment36);
gtk_container_add (GTK_CONTAINER (frame33), alignment36);
gtk_alignment_set_padding (GTK_ALIGNMENT (alignment36), 0, 0, 12, 0);
vbox30 = gtk_vbox_new (FALSE, 1);
gtk_widget_show (vbox30);
gtk_container_add (GTK_CONTAINER (alignment36), vbox30);
check_print_basename = gtk_check_button_new_with_mnemonic (_("Use the basename of the printed file"));
gtk_widget_show (check_print_basename);
gtk_box_pack_start (GTK_BOX (vbox30), check_print_basename, FALSE, FALSE, 0);
gtk_tooltips_set_tip (tooltips, check_print_basename, _("Print only the basename(without the path) of the printed file."), NULL);
gtk_button_set_focus_on_click (GTK_BUTTON (check_print_basename), FALSE);
hbox10 = gtk_hbox_new (FALSE, 5);
gtk_widget_show (hbox10);
gtk_box_pack_start (GTK_BOX (vbox30), hbox10, TRUE, TRUE, 0);
label203 = gtk_label_new (_("Date format:"));
gtk_widget_show (label203);
gtk_box_pack_start (GTK_BOX (hbox10), label203, FALSE, FALSE, 0);
entry_print_dateformat = gtk_entry_new ();
gtk_widget_show (entry_print_dateformat);
gtk_box_pack_start (GTK_BOX (hbox10), entry_print_dateformat, TRUE, TRUE, 0);
gtk_tooltips_set_tip (tooltips, entry_print_dateformat, _("Specify a format for the date and time stamp which is added to the page header on each page. You can use any conversion specifiers which can be used with the ANSI C strftime function."), NULL);
gtk_entry_set_invisible_char (GTK_ENTRY (entry_print_dateformat), 9679);
radio_print_gtk = gtk_radio_button_new_with_mnemonic (NULL, _("Use native GTK printing"));
gtk_widget_show (radio_print_gtk);
gtk_frame_set_label_widget (GTK_FRAME (frame31), radio_print_gtk);
gtk_button_set_focus_on_click (GTK_BUTTON (radio_print_gtk), FALSE);
gtk_radio_button_set_group (GTK_RADIO_BUTTON (radio_print_gtk), radio_print_external_group);
radio_print_external_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio_print_gtk));
label204 = gtk_label_new (_("<i>Notice: Native GTK printing is only available if Geany was built against GTK 2.10 (or above) <b>and</b> Geany is running with GTK 2.10 (or above).</i>"));
gtk_widget_show (label204);
gtk_box_pack_start (GTK_BOX (vbox27), label204, FALSE, TRUE, 5);
gtk_label_set_use_markup (GTK_LABEL (label204), TRUE);
gtk_label_set_line_wrap (GTK_LABEL (label204), TRUE);
gtk_misc_set_alignment (GTK_MISC (label204), 0.05, 0.5);
label201 = gtk_label_new (_("Printing"));
gtk_widget_show (label201);
gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook2), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook2), 9), label201);
dialog_action_area3 = GTK_DIALOG (prefs_dialog)->action_area;
gtk_widget_show (dialog_action_area3);
gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area3), GTK_BUTTONBOX_END);
@ -4457,12 +4591,8 @@ create_prefs_dialog (void)
GLADE_HOOKUP_OBJECT (prefs_dialog, frame26, "frame26");
GLADE_HOOKUP_OBJECT (prefs_dialog, alignment29, "alignment29");
GLADE_HOOKUP_OBJECT (prefs_dialog, table12, "table12");
GLADE_HOOKUP_OBJECT (prefs_dialog, entry_print, "entry_print");
GLADE_HOOKUP_OBJECT (prefs_dialog, button_print, "button_print");
GLADE_HOOKUP_OBJECT (prefs_dialog, image763, "image763");
GLADE_HOOKUP_OBJECT (prefs_dialog, label154, "label154");
GLADE_HOOKUP_OBJECT (prefs_dialog, entry_contextaction, "entry_contextaction");
GLADE_HOOKUP_OBJECT (prefs_dialog, label189, "label189");
GLADE_HOOKUP_OBJECT (prefs_dialog, entry_contextaction, "entry_contextaction");
GLADE_HOOKUP_OBJECT (prefs_dialog, button_contextaction, "button_contextaction");
GLADE_HOOKUP_OBJECT (prefs_dialog, image1919, "image1919");
GLADE_HOOKUP_OBJECT (prefs_dialog, label193, "label193");
@ -4495,6 +4625,31 @@ create_prefs_dialog (void)
GLADE_HOOKUP_OBJECT (prefs_dialog, button2, "button2");
GLADE_HOOKUP_OBJECT (prefs_dialog, label181, "label181");
GLADE_HOOKUP_OBJECT (prefs_dialog, label151, "label151");
GLADE_HOOKUP_OBJECT (prefs_dialog, vbox27, "vbox27");
GLADE_HOOKUP_OBJECT (prefs_dialog, frame32, "frame32");
GLADE_HOOKUP_OBJECT (prefs_dialog, alignment35, "alignment35");
GLADE_HOOKUP_OBJECT (prefs_dialog, hbox9, "hbox9");
GLADE_HOOKUP_OBJECT (prefs_dialog, label202, "label202");
GLADE_HOOKUP_OBJECT (prefs_dialog, entry_print_external_cmd, "entry_print_external_cmd");
GLADE_HOOKUP_OBJECT (prefs_dialog, button_print_external_cmd, "button_print_external_cmd");
GLADE_HOOKUP_OBJECT (prefs_dialog, image763, "image763");
GLADE_HOOKUP_OBJECT (prefs_dialog, radio_print_external, "radio_print_external");
GLADE_HOOKUP_OBJECT (prefs_dialog, frame31, "frame31");
GLADE_HOOKUP_OBJECT (prefs_dialog, alignment34, "alignment34");
GLADE_HOOKUP_OBJECT (prefs_dialog, vbox29, "vbox29");
GLADE_HOOKUP_OBJECT (prefs_dialog, check_print_linenumbers, "check_print_linenumbers");
GLADE_HOOKUP_OBJECT (prefs_dialog, check_print_pagenumbers, "check_print_pagenumbers");
GLADE_HOOKUP_OBJECT (prefs_dialog, check_print_pageheader, "check_print_pageheader");
GLADE_HOOKUP_OBJECT (prefs_dialog, frame33, "frame33");
GLADE_HOOKUP_OBJECT (prefs_dialog, alignment36, "alignment36");
GLADE_HOOKUP_OBJECT (prefs_dialog, vbox30, "vbox30");
GLADE_HOOKUP_OBJECT (prefs_dialog, check_print_basename, "check_print_basename");
GLADE_HOOKUP_OBJECT (prefs_dialog, hbox10, "hbox10");
GLADE_HOOKUP_OBJECT (prefs_dialog, label203, "label203");
GLADE_HOOKUP_OBJECT (prefs_dialog, entry_print_dateformat, "entry_print_dateformat");
GLADE_HOOKUP_OBJECT (prefs_dialog, radio_print_gtk, "radio_print_gtk");
GLADE_HOOKUP_OBJECT (prefs_dialog, label204, "label204");
GLADE_HOOKUP_OBJECT (prefs_dialog, label201, "label201");
GLADE_HOOKUP_OBJECT_NO_REF (prefs_dialog, dialog_action_area3, "dialog_action_area3");
GLADE_HOOKUP_OBJECT (prefs_dialog, button3, "button3");
GLADE_HOOKUP_OBJECT (prefs_dialog, button4, "button4");

View File

@ -51,6 +51,7 @@
#include "search.h"
#include "project.h"
#include "editor.h"
#include "printing.h"
static gchar *scribble_text = NULL;
@ -233,10 +234,18 @@ static void save_dialog_prefs(GKeyFile *config)
g_key_file_set_string(config, "tools", "make_cmd", prefs.tools_make_cmd ? prefs.tools_make_cmd : "");
g_key_file_set_string(config, "tools", "term_cmd", prefs.tools_term_cmd ? prefs.tools_term_cmd : "");
g_key_file_set_string(config, "tools", "browser_cmd", prefs.tools_browser_cmd ? prefs.tools_browser_cmd : "");
g_key_file_set_string(config, "tools", "print_cmd", prefs.tools_print_cmd ? prefs.tools_print_cmd : "");
g_key_file_set_string(config, "tools", "grep_cmd", prefs.tools_grep_cmd ? prefs.tools_grep_cmd : "");
g_key_file_set_string(config, PACKAGE, "context_action_cmd", prefs.context_action_cmd);
// printing
g_key_file_set_string(config, "printing", "print_cmd", printing_prefs.external_print_cmd ? printing_prefs.external_print_cmd : "");
g_key_file_set_boolean(config, "printing", "use_gtk_printing", printing_prefs.use_gtk_printing);
g_key_file_set_boolean(config, "printing", "print_line_numbers", printing_prefs.print_line_numbers);
g_key_file_set_boolean(config, "printing", "print_page_numbers", printing_prefs.print_page_numbers);
g_key_file_set_boolean(config, "printing", "print_page_header", printing_prefs.print_page_header);
g_key_file_set_boolean(config, "printing", "page_header_basename", printing_prefs.page_header_basename);
g_key_file_set_string(config, "printing", "page_header_datefmt", printing_prefs.page_header_datefmt);
// VTE
#ifdef HAVE_VTE
g_key_file_set_boolean(config, "VTE", "load_vte", vte_info.load_vte);
@ -598,6 +607,13 @@ static void load_dialog_prefs(GKeyFile *config)
prefs.tools_browser_cmd = utils_get_setting_string(config, "tools", "browser_cmd", tmp_string);
g_free(tmp_string);
tmp_string = g_find_program_in_path(GEANY_DEFAULT_TOOLS_GREP);
prefs.tools_grep_cmd = utils_get_setting_string(config, "tools", "grep_cmd", tmp_string);
g_free(tmp_string);
prefs.context_action_cmd = utils_get_setting_string(config, PACKAGE, "context_action_cmd", "");
// printing
tmp_string2 = g_find_program_in_path(GEANY_DEFAULT_TOOLS_PRINTCMD);
#ifdef G_OS_WIN32
// single quote paths on Win32 for g_spawn_command_line_async
@ -605,15 +621,20 @@ static void load_dialog_prefs(GKeyFile *config)
#else
tmp_string = g_strconcat(tmp_string2, " %f", NULL);
#endif
prefs.tools_print_cmd = utils_get_setting_string(config, "tools", "print_cmd", tmp_string);
printing_prefs.external_print_cmd = utils_get_setting_string(config, "printing", "print_cmd", tmp_string);
g_free(tmp_string);
g_free(tmp_string2);
tmp_string = g_find_program_in_path(GEANY_DEFAULT_TOOLS_GREP);
prefs.tools_grep_cmd = utils_get_setting_string(config, "tools", "grep_cmd", tmp_string);
g_free(tmp_string);
prefs.context_action_cmd = utils_get_setting_string(config, PACKAGE, "context_action_cmd", "");
#if GTK_CHECK_VERSION(2, 10, 0)
printing_prefs.use_gtk_printing = utils_get_setting_boolean(config, "printing", "use_gtk_printing", TRUE);
#else
printing_prefs.use_gtk_printing = utils_get_setting_boolean(config, "printing", "use_gtk_printing", FALSE);
#endif
printing_prefs.print_line_numbers = utils_get_setting_boolean(config, "printing", "print_line_numbers", TRUE);
printing_prefs.print_page_numbers = utils_get_setting_boolean(config, "printing", "print_page_numbers", TRUE);
printing_prefs.print_page_header = utils_get_setting_boolean(config, "printing", "print_page_header", TRUE);
printing_prefs.page_header_basename = utils_get_setting_boolean(config, "printing", "page_header_basename", FALSE);
printing_prefs.page_header_datefmt = utils_get_setting_string(config, "printing", "page_header_datefmt", "%c");
}

View File

@ -67,6 +67,7 @@
#include "tools.h"
#include "navqueue.h"
#include "plugins.h"
#include "printing.h"
#ifdef HAVE_SOCKET
# include "socket.h"
@ -293,13 +294,14 @@ static void main_init(void)
gtk_menu_item_set_submenu(GTK_MENU_ITEM(ui_widgets.recent_files_menuitem),
ui_widgets.recent_files_menubar);
// store important pointers in the GeanyApp structure
// store important pointers for later reference
app->toolbar = lookup_widget(app->window, "toolbar1");
app->treeview_notebook = lookup_widget(app->window, "notebook3");
app->notebook = lookup_widget(app->window, "notebook1");
app->statusbar = lookup_widget(app->window, "statusbar");
app->popup_menu = create_edit_menu1();
ui_widgets.toolbar_menu = create_toolbar_popup_menu1();
ui_widgets.print_page_setup = lookup_widget(app->window, "page_setup1");
ui_widgets.popup_goto_items[0] = lookup_widget(app->popup_menu, "goto_tag_definition1");
ui_widgets.popup_goto_items[1] = lookup_widget(app->popup_menu, "goto_tag_declaration1");
ui_widgets.popup_goto_items[2] = lookup_widget(app->popup_menu, "find_usage1");
@ -328,6 +330,12 @@ static void main_init(void)
gtk_widget_set_name(app->window, "GeanyMainWindow");
gtk_widget_set_name(ui_widgets.toolbar_menu, "GeanyToolbarMenu");
gtk_widget_set_name(app->popup_menu, "GeanyEditMenu");
#if ! GTK_CHECK_VERSION(2, 10, 0)
// hide Page setup menu item, it isn't supported with non-GTK printing
gtk_widget_hide(ui_widgets.print_page_setup);
#endif
}
@ -825,8 +833,9 @@ void main_quit()
g_free(prefs.tools_make_cmd);
g_free(prefs.tools_term_cmd);
g_free(prefs.tools_browser_cmd);
g_free(prefs.tools_print_cmd);
g_free(prefs.tools_grep_cmd);
g_free(printing_prefs.external_print_cmd);
g_free(printing_prefs.page_header_datefmt);
g_strfreev(ui_prefs.custom_commands);
while (! g_queue_is_empty(ui_prefs.recent_queue))
{

View File

@ -36,18 +36,23 @@ ALL_GTK_LIBS= \
-L"$(PREFIX)/lib" \
-lgtk-win32-2.0 -lgdk-win32-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lpangowin32-1.0 -lgdi32 \
-lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lglib-2.0 -lintl -liconv
#-lcairo -lpangocairo-1.0
# these things are for GTK >= 2.8
# (should be same as with MSYS: pkg-config --libs gtk+-2.0 gthread-2.0)
#"$(PREFIX)/lib/libcairo.dll.a" \
#"$(PREFIX)/lib/asprintf.lib" \
#"$(PREFIX)/lib/charset.lib" \
ifdef GTK210
PRINTING_LIBS=-lcairo -lpangocairo-1.0
else
PRINTING_LIBS=
endif
CCFLAGS=-Wall -O2 -g -mms-bitfields $(DEFINES) $(INCLUDEDIRS)
OBJS = about.o build.o callbacks.o dialogs.o document.o editor.o encodings.o filetypes.o \
geanyobject.o highlighting.o interface.o keybindings.o keyfile.o main.o msgwindow.o \
navqueue.o notebook.o plugins.o prefs.o project.o sciwrappers.o search.o \
navqueue.o notebook.o plugins.o prefs.o printing.o project.o sciwrappers.o search.o \
socket.o support.o symbols.o templates.o treeviews.o tools.o ui_utils.o utils.o win32.o
.c.o:
@ -72,7 +77,7 @@ binclean:
$(TARGET): $(OBJS) $(RES) ../scintilla/scintilla.a ../tagmanager/tagmanager.a
$(CXX) $(OBJS) $(RES) -o $(TARGET) \
../scintilla/scintilla.a ../tagmanager/tagmanager.a $(ALL_GTK_LIBS) \
../scintilla/scintilla.a ../tagmanager/tagmanager.a $(ALL_GTK_LIBS) $(PRINTING_LIBS) \
-mwindows -lkernel32 -limm32 -lshell32 -lole32 -luuid -lcomdlg32 -lcomctl32 -liberty -lwsock32
deps.mak:

View File

@ -47,6 +47,7 @@
#include "editor.h"
#include "main.h"
#include "treeviews.h"
#include "printing.h"
#ifdef HAVE_VTE
# include "vte.h"
@ -77,6 +78,8 @@ static void on_show_notebook_tabs_toggled(GtkToggleButton *togglebutton, gpointe
static void on_use_folding_toggled(GtkToggleButton *togglebutton, gpointer user_data);
static void on_open_encoding_toggled(GtkToggleButton *togglebutton, gpointer user_data);
static void on_openfiles_visible_toggled(GtkToggleButton *togglebutton, gpointer user_data);
static void on_prefs_print_radio_button_toggled(GtkToggleButton *togglebutton, gpointer user_data);
static void on_prefs_print_page_header_toggled(GtkToggleButton *togglebutton, gpointer user_data);
enum
@ -411,9 +414,6 @@ void prefs_init_dialog(void)
if (prefs.tools_browser_cmd)
gtk_entry_set_text(GTK_ENTRY(lookup_widget(ui_widgets.prefs_dialog, "entry_browser")), prefs.tools_browser_cmd);
if (prefs.tools_print_cmd)
gtk_entry_set_text(GTK_ENTRY(lookup_widget(ui_widgets.prefs_dialog, "entry_print")), prefs.tools_print_cmd);
if (prefs.tools_grep_cmd)
gtk_entry_set_text(GTK_ENTRY(lookup_widget(ui_widgets.prefs_dialog, "entry_grep")), prefs.tools_grep_cmd);
@ -438,6 +438,49 @@ void prefs_init_dialog(void)
// Keybindings
init_keybindings();
// Printing
{
GtkWidget *widget_gtk = lookup_widget(ui_widgets.prefs_dialog, "radio_print_gtk");
if (printing_prefs.use_gtk_printing)
widget = widget_gtk;
else
widget = lookup_widget(ui_widgets.prefs_dialog, "radio_print_external");
#if GTK_CHECK_VERSION(2, 10, 0)
if (gtk_check_version(2, 10, 0) != NULL)
#endif
{
gtk_widget_set_sensitive(widget_gtk, FALSE); // disable the whole option block
widget = lookup_widget(ui_widgets.prefs_dialog, "radio_print_external");
}
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE);
on_prefs_print_radio_button_toggled(GTK_TOGGLE_BUTTON(widget_gtk), NULL);
}
if (printing_prefs.external_print_cmd)
gtk_entry_set_text(
GTK_ENTRY(lookup_widget(ui_widgets.prefs_dialog, "entry_print_external_cmd")),
printing_prefs.external_print_cmd);
widget = lookup_widget(ui_widgets.prefs_dialog, "check_print_linenumbers");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), printing_prefs.print_line_numbers);
widget = lookup_widget(ui_widgets.prefs_dialog, "check_print_pagenumbers");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), printing_prefs.print_page_numbers);
widget = lookup_widget(ui_widgets.prefs_dialog, "check_print_pageheader");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), printing_prefs.print_page_header);
on_prefs_print_page_header_toggled(GTK_TOGGLE_BUTTON(widget), NULL);
widget = lookup_widget(ui_widgets.prefs_dialog, "check_print_basename");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), printing_prefs.page_header_basename);
if (printing_prefs.page_header_datefmt)
gtk_entry_set_text(
GTK_ENTRY(lookup_widget(ui_widgets.prefs_dialog, "entry_print_dateformat")),
printing_prefs.page_header_datefmt);
#ifndef HAVE_PLUGINS
gtk_widget_set_sensitive(lookup_widget(ui_widgets.prefs_dialog, "check_plugins"), FALSE);
#endif
@ -748,10 +791,6 @@ on_prefs_button_clicked(GtkDialog *dialog, gint response, gpointer user_data)
g_free(prefs.tools_browser_cmd);
prefs.tools_browser_cmd = g_strdup(gtk_entry_get_text(GTK_ENTRY(widget)));
widget = lookup_widget(ui_widgets.prefs_dialog, "entry_print");
g_free(prefs.tools_print_cmd);
prefs.tools_print_cmd = g_strdup(gtk_entry_get_text(GTK_ENTRY(widget)));
widget = lookup_widget(ui_widgets.prefs_dialog, "entry_grep");
g_free(prefs.tools_grep_cmd);
prefs.tools_grep_cmd = g_strdup(gtk_entry_get_text(GTK_ENTRY(widget)));
@ -782,6 +821,32 @@ on_prefs_button_clicked(GtkDialog *dialog, gint response, gpointer user_data)
// Keybindings
if (edited) keybindings_write_to_file();
// Printing
widget = lookup_widget(ui_widgets.prefs_dialog, "radio_print_gtk");
printing_prefs.use_gtk_printing = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
widget = lookup_widget(ui_widgets.prefs_dialog, "entry_print_external_cmd");
g_free(printing_prefs.external_print_cmd);
printing_prefs.external_print_cmd = g_strdup(gtk_entry_get_text(GTK_ENTRY(widget)));
widget = lookup_widget(ui_widgets.prefs_dialog, "check_print_linenumbers");
printing_prefs.print_line_numbers = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
widget = lookup_widget(ui_widgets.prefs_dialog, "check_print_pagenumbers");
printing_prefs.print_page_numbers = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
widget = lookup_widget(ui_widgets.prefs_dialog, "check_print_pageheader");
printing_prefs.print_page_header = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
widget = lookup_widget(ui_widgets.prefs_dialog, "check_print_basename");
printing_prefs.page_header_basename = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
widget = lookup_widget(ui_widgets.prefs_dialog, "entry_print_dateformat");
g_free(printing_prefs.page_header_datefmt);
printing_prefs.page_header_datefmt = g_strdup(gtk_entry_get_text(GTK_ENTRY(widget)));
#ifdef HAVE_VTE
widget = lookup_widget(ui_widgets.prefs_dialog, "check_vte");
vte_info.load_vte = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
@ -1198,6 +1263,24 @@ static void on_openfiles_visible_toggled(GtkToggleButton *togglebutton, gpointer
}
static void on_prefs_print_radio_button_toggled(GtkToggleButton *togglebutton, gpointer user_data)
{
gboolean sens = gtk_toggle_button_get_active(togglebutton);
gtk_widget_set_sensitive(lookup_widget(ui_widgets.prefs_dialog, "vbox29"), sens);
gtk_widget_set_sensitive(lookup_widget(ui_widgets.prefs_dialog, "hbox9"), ! sens);
}
static void on_prefs_print_page_header_toggled(GtkToggleButton *togglebutton, gpointer user_data)
{
gboolean sens = gtk_toggle_button_get_active(togglebutton);
gtk_widget_set_sensitive(lookup_widget(ui_widgets.prefs_dialog, "check_print_basename"), sens);
gtk_widget_set_sensitive(lookup_widget(ui_widgets.prefs_dialog, "entry_print_dateformat"), sens);
}
void prefs_show_dialog(void)
{
if (ui_widgets.prefs_dialog == NULL)
@ -1254,10 +1337,18 @@ void prefs_show_dialog(void)
"clicked", G_CALLBACK(on_prefs_tools_button_clicked), lookup_widget(ui_widgets.prefs_dialog, "entry_grep"));
// tools commands
g_signal_connect((gpointer) lookup_widget(ui_widgets.prefs_dialog, "button_print"),
"clicked", G_CALLBACK(on_prefs_tools_button_clicked), lookup_widget(ui_widgets.prefs_dialog, "entry_print"));
g_signal_connect((gpointer) lookup_widget(ui_widgets.prefs_dialog, "button_contextaction"),
"clicked", G_CALLBACK(on_prefs_tools_button_clicked), lookup_widget(ui_widgets.prefs_dialog, "entry_contextaction"));
"clicked", G_CALLBACK(on_prefs_tools_button_clicked), lookup_widget(ui_widgets.prefs_dialog, "entry_contextaction"));
g_signal_connect((gpointer) lookup_widget(ui_widgets.prefs_dialog, "button_contextaction"),
"clicked", G_CALLBACK(on_prefs_tools_button_clicked), lookup_widget(ui_widgets.prefs_dialog, "entry_contextaction"));
// printing
g_signal_connect((gpointer) lookup_widget(ui_widgets.prefs_dialog, "button_print_external_cmd"),
"clicked", G_CALLBACK(on_prefs_tools_button_clicked), lookup_widget(ui_widgets.prefs_dialog, "entry_print_external_cmd"));
g_signal_connect((gpointer) lookup_widget(ui_widgets.prefs_dialog, "radio_print_gtk"),
"toggled", G_CALLBACK(on_prefs_print_radio_button_toggled), NULL);
g_signal_connect((gpointer) lookup_widget(ui_widgets.prefs_dialog, "check_print_pageheader"),
"toggled", G_CALLBACK(on_prefs_print_page_header_toggled), NULL);
g_signal_connect((gpointer) lookup_widget(ui_widgets.prefs_dialog, "check_toolbar_show"),
"toggled", G_CALLBACK(on_toolbar_show_toggled), NULL);

View File

@ -25,7 +25,7 @@
#define GEANY_PREFS_H 1
/* Preferences dialog settings.
* (See also EditorPrefs in editor.h).
* (See also EditorPrefs in editor.h and PrintingPrefs in printing.h).
* Remember to increment abi_version in plugindata.h when changing items. */
typedef struct GeanyPrefs
{
@ -82,7 +82,7 @@ typedef struct GeanyPrefs
gchar *tools_browser_cmd;
gchar *tools_make_cmd;
gchar *tools_term_cmd;
gchar *tools_print_cmd;
gchar *tools_print_cmd; /// TODO unused: remove this at next abi_verison change
gchar *tools_grep_cmd;
gchar *context_action_cmd;

839
src/printing.c Normal file
View File

@ -0,0 +1,839 @@
/*
* printing.c - this file is part of Geany, a fast and lightweight IDE
*
* Copyright 2007 Enrico Tröger <enrico.troeger@uvena.de>
* Copyright 2007 Nick Treleaven <nick.treleaven@btinternet.com>
*
* 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.
*
* $Id$
*/
/*
* GTK 2.10 printing support
* (basic code layout were adopted from Sylpheed's printing implementation, thanks)
*/
#include <math.h>
#include <time.h>
#include <string.h>
#include "geany.h"
#include "printing.h"
#include "prefs.h"
#include "document.h"
#include "sciwrappers.h"
#include "editor.h"
#include "sciwrappers.h"
#include "utils.h"
#include "support.h"
#include "dialogs.h"
#include "utils.h"
#include "msgwindow.h"
PrintingPrefs printing_prefs;
#if GTK_CHECK_VERSION(2, 10, 0)
#define ROTATE_RGB(color) \
(((color) & 0xFF0000) >> 16) + ((color) & 0x00FF00) + (((color) & 0x0000FF) << 16)
#define ADD_ATTR(l, a) \
pango_attr_list_insert((l), (a)); \
(a)->start_index = 0; \
(a)->end_index = -1;
enum
{
FORE = 0,
BACK,
BOLD,
ITALIC,
MAX_TYPES
};
// document-related variables
typedef struct
{
gint idx;
gint font_width;
gint lines;
gint n_pages;
gint lines_per_page;
gint max_line_number_margin;
gint cur_line;
gint cur_pos;
gint styles[STYLE_MAX + 1][MAX_TYPES];
gdouble line_height;
gboolean long_line; // whether we have a wrapped line on page end to take care of on next page
// set in begin_print() to hold the time when printing was started to ensure all printed
// pages have the same date and time (in case of slow machines and many pages where rendering
// takes more than a second)
time_t print_time;
PangoLayout *layout; // commonly used layout object
} DocInfo;
// widget references for the custom widget in the print dialog
typedef struct
{
GtkWidget *check_print_linenumbers;
GtkWidget *check_print_pagenumbers;
GtkWidget *check_print_pageheader;
GtkWidget *check_print_basename;
GtkWidget *entry_print_dateformat;
} PrintWidgets;
static GtkPrintSettings *settings = NULL;
static GtkPageSetup *page_setup = NULL;
// returns the "width" (count of needed characters) for the given number
static gint get_line_numbers_arity(gint x)
{
gint a = 0;
while ((x /= 10) != 0)
a++;
return a;
}
// split a RGB colour into the three colour components
static void get_rgb_values(gint c, gint *r, gint *g, gint *b)
{
c = ROTATE_RGB(c);
*r = c % 256;
*g = (c & - 16711936) / 256;
*b = (c & 0xff0000) / 65536;
*r *= 257;
*g *= 257;
*b *= 257;
}
// creates a commonly used layout object from the given context for use in get_page_count and
// draw_page
static PangoLayout *setup_pango_layout(GtkPrintContext *context, PangoFontDescription *desc)
{
PangoLayout *layout;
layout = gtk_print_context_create_pango_layout(context);
pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
pango_layout_set_spacing(layout, 0);
pango_layout_set_attributes(layout, NULL);
pango_layout_set_font_description(layout, desc);
return layout;
}
static gint get_font_width(GtkPrintContext *context, PangoFontDescription *desc)
{
PangoContext *pc;
PangoFontMetrics *metrics;
gint width;
pc = gtk_print_context_create_pango_context(context);
metrics = pango_context_get_metrics(pc, desc, pango_context_get_language(pc));
/// TODO is this the best result we can get?
// digit and char width are mostly equal for monospace fonts, char width might be
// for dual width characters(e.g. Japanese) so use digit width to get sure we get the width
// for one character
width = pango_font_metrics_get_approximate_digit_width(metrics) / PANGO_SCALE;
pango_font_metrics_unref(metrics);
return width;
}
static gint get_page_count(GtkPrintContext *context, DocInfo *dinfo)
{
gdouble width, height;
gint layout_h;
gint i, j, lines_left;
gchar *line_buf;
if (dinfo == NULL)
return -1;
width = gtk_print_context_get_width(context);
height = gtk_print_context_get_height(context);
if (printing_prefs.print_line_numbers)
// remove line number margin space from overall width
width -= dinfo->max_line_number_margin * dinfo->font_width;
pango_layout_set_width(dinfo->layout, width * PANGO_SCALE);
// add test text to get line height
pango_layout_set_text(dinfo->layout, "Test 1", -1);
pango_layout_get_size(dinfo->layout, NULL, &layout_h);
if (layout_h <= 0)
{
geany_debug("Invalid layout_h (%d). Falling back to default height (%d)",
layout_h, 100 * PANGO_SCALE);
layout_h = 100 * PANGO_SCALE;
}
dinfo->line_height = (gdouble)layout_h / PANGO_SCALE;
dinfo->lines_per_page = ceil((height - dinfo->line_height) / dinfo->line_height);
#ifdef GEANY_PRINT_DEBUG
geany_debug("max lines_per_page: %d", dinfo->lines_per_page);
#endif
if (printing_prefs.print_page_numbers)
dinfo->lines_per_page -= 2;
if (printing_prefs.print_page_header)
dinfo->lines_per_page -= 3;
lines_left = dinfo->lines_per_page;
i = 0;
for (j = 0; j < dinfo->lines; j++)
{
gint lines = 1;
gint line_width;
line_buf = sci_get_line(doc_list[dinfo->idx].sci, j);
line_width = (g_utf8_strlen(line_buf, -1) + 1) * dinfo->font_width;
if (line_width > width)
lines = ceil(line_width / width);
#ifdef GEANY_PRINT_DEBUG
if (lines != 1) geany_debug("%d %d", j+1, lines);
#endif
while (lines_left < lines)
{
lines -= lines_left;
lines_left = dinfo->lines_per_page;
i++;
}
lines_left -= lines;
g_free(line_buf);
}
return i + 1;
}
static void add_page_header(PangoLayout *layout, cairo_t *cr, DocInfo *dinfo, gint width, gint page_nr)
{
gint ph_height = dinfo->line_height * 3;
gchar *data;
gchar *datetime;
gchar *file_name = (printing_prefs.page_header_basename) ?
g_path_get_basename(doc_list[dinfo->idx].file_name) :
g_strdup(doc_list[dinfo->idx].file_name);
// draw the frame
cairo_set_source_rgb(cr, 0, 0, 0);
cairo_rectangle(cr, 2, 2, width - 4, ph_height - 4);
cairo_stroke(cr);
// width - 8: 2px between doc border and frame border, 2px between frame border and text
// and this on left and right side, so (2 + 2) * 2
pango_layout_set_width(layout, (width - 8) * PANGO_SCALE);
if ((g_utf8_strlen(file_name, -1) * dinfo->font_width) >= ((width - 4) - (dinfo->font_width * 2)))
// if the filename is wider than the available space on the line, skip parts of it
pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_MIDDLE);
data = g_strdup_printf("<b>%s</b>", file_name);
pango_layout_set_markup(layout, data, -1);
pango_layout_set_alignment(layout, PANGO_ALIGN_LEFT);
cairo_move_to(cr, 4, dinfo->line_height * 0.5);
pango_cairo_show_layout(cr, layout);
g_free(data);
g_free(file_name);
data = g_strdup_printf("<b>page %d of %d</b>", page_nr + 1, dinfo->n_pages);
pango_layout_set_markup(layout, data, -1);
pango_layout_set_alignment(layout, PANGO_ALIGN_LEFT);
cairo_move_to(cr, 4, dinfo->line_height * 1.5);
pango_cairo_show_layout(cr, layout);
g_free(data);
datetime = utils_get_date_time(printing_prefs.page_header_datefmt, &(dinfo->print_time));
data = g_strdup_printf("<b>%s</b>", datetime);
pango_layout_set_markup(layout, data, -1);
pango_layout_set_alignment(layout, PANGO_ALIGN_RIGHT);
cairo_move_to(cr, 2, dinfo->line_height * 1.5);
pango_cairo_show_layout(cr, layout);
g_free(data);
g_free(datetime);
// reset layout and re-position cairo context
pango_layout_set_alignment(layout, PANGO_ALIGN_LEFT);
pango_layout_set_ellipsize(layout, FALSE);
pango_layout_set_justify(layout, FALSE);
pango_layout_set_width(layout, width * PANGO_SCALE);
cairo_move_to(cr, 0, dinfo->line_height * 3);
}
static void custom_widget_apply(GtkPrintOperation *operation, GtkWidget *widget, gpointer user_data)
{
PrintWidgets *w = user_data;
printing_prefs.print_line_numbers =
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w->check_print_linenumbers));
printing_prefs.print_page_numbers =
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w->check_print_pagenumbers));
printing_prefs.print_page_header =
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w->check_print_pageheader));
printing_prefs.page_header_basename =
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w->check_print_basename));
g_free(printing_prefs.page_header_datefmt);
printing_prefs.page_header_datefmt =
g_strdup(gtk_entry_get_text(GTK_ENTRY(w->entry_print_dateformat)));
}
static void on_page_header_toggled(GtkToggleButton *togglebutton, gpointer user_data)
{
gboolean sens = gtk_toggle_button_get_active(togglebutton);
PrintWidgets *w = user_data;
gtk_widget_set_sensitive(w->check_print_basename, sens);
gtk_widget_set_sensitive(w->entry_print_dateformat, sens);
}
static GtkWidget *create_custom_widget(GtkPrintOperation *operation, gpointer user_data)
{ // copied from interface.c
GtkWidget *page;
GtkWidget *frame33;
GtkWidget *alignment36;
GtkWidget *vbox30;
GtkWidget *hbox10;
GtkWidget *label203;
GtkTooltips *tooltips = gtk_tooltips_new();
PrintWidgets *w = user_data;
gtk_print_operation_set_custom_tab_label(operation, _("Document Setup"));
page = gtk_vbox_new(FALSE, 0);
gtk_container_set_border_width(GTK_CONTAINER(page), 5);
w->check_print_linenumbers = gtk_check_button_new_with_mnemonic(_("Print line numbers"));
gtk_box_pack_start(GTK_BOX(page), w->check_print_linenumbers, FALSE, FALSE, 0);
gtk_tooltips_set_tip(tooltips, w->check_print_linenumbers, _("Add line numbers to the printed page."), NULL);
gtk_button_set_focus_on_click(GTK_BUTTON(w->check_print_linenumbers), FALSE);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w->check_print_linenumbers), printing_prefs.print_line_numbers);
w->check_print_pagenumbers = gtk_check_button_new_with_mnemonic(_("Print page numbers"));
gtk_box_pack_start(GTK_BOX(page), w->check_print_pagenumbers, FALSE, FALSE, 0);
gtk_tooltips_set_tip(tooltips, w->check_print_pagenumbers, _("Add page numbers at the bottom of each page. It takes 2 lines of the page."), NULL);
gtk_button_set_focus_on_click(GTK_BUTTON(w->check_print_pagenumbers), FALSE);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w->check_print_pagenumbers), printing_prefs.print_page_numbers);
w->check_print_pageheader = gtk_check_button_new_with_mnemonic(_("Print page header"));
gtk_box_pack_start(GTK_BOX(page), w->check_print_pageheader, FALSE, FALSE, 0);
gtk_tooltips_set_tip(tooltips, w->check_print_pageheader, _("Adds a little header to every page containing the page number, the filename and the current date(see below). It takes 3 lines of the page."), NULL);
gtk_button_set_focus_on_click(GTK_BUTTON(w->check_print_pageheader), FALSE);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w->check_print_pageheader), printing_prefs.print_page_header);
g_signal_connect((gpointer) w->check_print_pageheader, "toggled", G_CALLBACK(on_page_header_toggled), w);
frame33 = gtk_frame_new(NULL);
gtk_box_pack_start(GTK_BOX(page), frame33, FALSE, FALSE, 0);
gtk_frame_set_label_align(GTK_FRAME(frame33), 0, 0);
gtk_frame_set_shadow_type(GTK_FRAME(frame33), GTK_SHADOW_NONE);
alignment36 = gtk_alignment_new(0, 0.5, 1, 1);
gtk_container_add(GTK_CONTAINER(frame33), alignment36);
gtk_alignment_set_padding(GTK_ALIGNMENT(alignment36), 0, 0, 12, 0);
vbox30 = gtk_vbox_new(FALSE, 1);
gtk_container_add(GTK_CONTAINER(alignment36), vbox30);
w->check_print_basename = gtk_check_button_new_with_mnemonic(_("Use the basename of the printed file"));
gtk_box_pack_start(GTK_BOX(vbox30), w->check_print_basename, FALSE, FALSE, 0);
gtk_tooltips_set_tip(tooltips, w->check_print_basename, _("Print only the basename(without the path) of the printed file."), NULL);
gtk_button_set_focus_on_click(GTK_BUTTON(w->check_print_basename), FALSE);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w->check_print_basename), printing_prefs.page_header_basename);
hbox10 = gtk_hbox_new(FALSE, 5);
gtk_box_pack_start(GTK_BOX(vbox30), hbox10, TRUE, TRUE, 0);
label203 = gtk_label_new(_("Date format:"));
gtk_box_pack_start(GTK_BOX(hbox10), label203, FALSE, FALSE, 0);
w->entry_print_dateformat = gtk_entry_new();
gtk_box_pack_start(GTK_BOX(hbox10), w->entry_print_dateformat, TRUE, TRUE, 0);
gtk_tooltips_set_tip(tooltips, w->entry_print_dateformat, _("Specify a format for the date and time stamp which is added to the page header on each page. You can use any conversion specifiers which can be used with the ANSI C strftime function."), NULL);
gtk_entry_set_text(GTK_ENTRY(w->entry_print_dateformat), printing_prefs.page_header_datefmt);
on_page_header_toggled(GTK_TOGGLE_BUTTON(w->check_print_pageheader), w);
gtk_widget_show_all(page);
return page;
}
static void end_print(GtkPrintOperation *operation, GtkPrintContext *context, gpointer user_data)
{
DocInfo *dinfo = user_data;
if (dinfo == NULL)
return;
g_object_unref(dinfo->layout);
}
static void begin_print(GtkPrintOperation *operation, GtkPrintContext *context, gpointer user_data)
{
DocInfo *dinfo = user_data;
PangoFontDescription *desc;
gint i;
if (dinfo == NULL)
return;
desc = pango_font_description_from_string(prefs.editor_font);
// init dinfo fields
dinfo->lines = sci_get_line_count(doc_list[dinfo->idx].sci);
dinfo->lines_per_page = 0;
dinfo->cur_line = 0;
dinfo->cur_pos = 0;
dinfo->long_line = FALSE;
dinfo->print_time = time(NULL);
dinfo->max_line_number_margin = get_line_numbers_arity(dinfo->lines) + 1;
// increase font width by 1 (looks better)
dinfo->font_width = get_font_width(context, desc) + 1;
// create a PangoLayout to be commonly used in get_page_count and draw_page
dinfo->layout = setup_pango_layout(context, desc);
// this is necessary because of possible line breaks on the printed page and then
// lines_per_page differs from document line count
dinfo->n_pages = get_page_count(context, dinfo);
// read all styles from Scintilla
for (i = 0; i <= STYLE_MAX; i++)
{
dinfo->styles[i][FORE] = ROTATE_RGB(scintilla_send_message(
doc_list[dinfo->idx].sci, SCI_STYLEGETFORE, i, 0));
if (i == STYLE_LINENUMBER)
{ // ignore background colour for line number margin to avoid trouble with wrapped lines
dinfo->styles[STYLE_LINENUMBER][BACK] = ROTATE_RGB(scintilla_send_message(
doc_list[dinfo->idx].sci, SCI_STYLEGETBACK, STYLE_DEFAULT, 0));
}
else
{
dinfo->styles[i][BACK] = ROTATE_RGB(scintilla_send_message(
doc_list[dinfo->idx].sci, SCI_STYLEGETBACK, i, 0));
}
dinfo->styles[i][BOLD] =
scintilla_send_message(doc_list[dinfo->idx].sci, SCI_STYLEGETBOLD, i, 0);
dinfo->styles[i][ITALIC] =
scintilla_send_message(doc_list[dinfo->idx].sci, SCI_STYLEGETITALIC, i, 0);
}
if (dinfo->n_pages >= 0)
gtk_print_operation_set_n_pages(operation, dinfo->n_pages);
pango_font_description_free(desc);
}
static void draw_page(GtkPrintOperation *operation, GtkPrintContext *context,
gint page_nr, gpointer user_data)
{
DocInfo *dinfo = user_data;
cairo_t *cr;
gdouble width, height;
gdouble x, y;
//~ gint layout_h;
gint count;
GString *str;
if (dinfo == NULL || page_nr >= dinfo->n_pages)
return;
#ifdef GEANY_PRINT_DEBUG
geany_debug("draw_page = %d, pages = %d, (real) lines_per_page = %d",
page_nr, dinfo->n_pages, dinfo->lines_per_page);
#endif
str = g_string_sized_new(256);
cr = gtk_print_context_get_cairo_context(context);
width = gtk_print_context_get_width(context);
height = gtk_print_context_get_height(context);
cairo_set_source_rgb(cr, 0, 0, 0);
#ifdef GEANY_PRINT_DEBUG
cairo_set_line_width(cr, 0.2);
cairo_rectangle(cr, 0, 0, width, height);
cairo_stroke(cr);
#endif
cairo_move_to(cr, 0, 0);
pango_layout_set_width(dinfo->layout, width * PANGO_SCALE);
if (printing_prefs.print_page_header)
add_page_header(dinfo->layout, cr, dinfo, width, page_nr);
count = 0; // the actual line counter for the current page, might be different from
// dinfo->cur_line due to possible line breaks
while (count < dinfo->lines_per_page)
{
gchar c = 'a';
gint style = -1;
PangoAttrList *layout_attr;
PangoAttribute *attr;
gint colours[3] = { 0 };
gboolean add_linenumber = TRUE;
gboolean at_eol;
while (count < dinfo->lines_per_page && c != '\0')
{
at_eol = FALSE;
g_string_erase(str, 0, str->len); // clear the string
// line numbers
if (printing_prefs.print_line_numbers && add_linenumber)
{
// if we had a wrapped line on the last page which needs to be continued, don't
// add a line number
if (dinfo->long_line)
{
add_linenumber = FALSE;
}
else
{
gchar *line_number = NULL;
gint cur_line_number_margin = get_line_numbers_arity(dinfo->cur_line + 1);
gchar *fill = g_strnfill(
dinfo->max_line_number_margin - cur_line_number_margin - 1, ' ');
line_number = g_strdup_printf("%s%d ", fill, dinfo->cur_line + 1);
g_string_append(str, line_number);
dinfo->cur_line++; // increase document line
add_linenumber = FALSE;
style = STYLE_LINENUMBER;
c = 'a'; // dummy value
g_free(fill);
g_free(line_number);
}
}
// data
else
{
style = sci_get_style_at(doc_list[dinfo->idx].sci, dinfo->cur_pos);
c = sci_get_char_at(doc_list[dinfo->idx].sci, dinfo->cur_pos);
if (c == '\0' || style == -1)
{ // if c gets 0, we are probably out of document boundaries, so stop
count = dinfo->lines_per_page; // to break out of outer loop
break;
}
dinfo->cur_pos++;
if (c == '\t')
{ // convert tabs to spaces which seems better than using Pango tabs
gchar *s = g_strnfill(editor_prefs.tab_width, ' ');
g_string_append(str, s);
g_free(s);
}
// don't add line breaks, they are handled manually below
else if (c == '\r' || c == '\n')
{
gchar c_next = sci_get_char_at(doc_list[dinfo->idx].sci, dinfo->cur_pos);
at_eol = TRUE;
if (c == '\r' && c_next == '\n')
dinfo->cur_pos++; // skip LF part of CR/LF
}
else
{
g_string_append_c(str, c); // finally add the character
// handle UTF-8: since we add char by char (better: byte by byte), we need to
// keep UTF-8 characters together(maybe two bytes for one character)
// the input is always UTF-8 and c is signed, so all non-Ascii
// characters are less than 0 and consist of all bytes less than 0.
// style doesn't change since it is only one character with multiple bytes.
while (c < 0)
{
c = sci_get_char_at(doc_list[dinfo->idx].sci, dinfo->cur_pos);
g_string_append_c(str, c);
dinfo->cur_pos++;
}
}
}
if (! at_eol)
{
// set text
pango_layout_set_text(dinfo->layout, str->str, -1);
// attributes
layout_attr = pango_attr_list_new();
// foreground colour
get_rgb_values(dinfo->styles[style][FORE], &colours[0], &colours[1], &colours[2]);
attr = pango_attr_foreground_new(colours[0], colours[1], colours[2]);
ADD_ATTR(layout_attr, attr);
// background colour
get_rgb_values(dinfo->styles[style][BACK], &colours[0], &colours[1], &colours[2]);
attr = pango_attr_background_new(colours[0], colours[1], colours[2]);
ADD_ATTR(layout_attr, attr);
// bold text
if (dinfo->styles[style][BOLD])
{
attr = pango_attr_weight_new(PANGO_WEIGHT_BOLD);
ADD_ATTR(layout_attr, attr);
}
// italic text
if (dinfo->styles[style][ITALIC])
{
attr = pango_attr_style_new(PANGO_STYLE_ITALIC);
ADD_ATTR(layout_attr, attr);
}
pango_layout_set_attributes(dinfo->layout, layout_attr);
pango_layout_context_changed(dinfo->layout);
pango_attr_list_unref(layout_attr);
}
cairo_get_current_point(cr, &x, &y);
// normal line break at eol character in document
if (at_eol)
{
//~ pango_layout_get_size(dinfo->layout, NULL, &layout_h);
//~ cairo_move_to(cr, 0, y + (gdouble)layout_h / PANGO_SCALE);
cairo_move_to(cr, 0, y + dinfo->line_height);
count++;
add_linenumber = TRUE; // we added a new document line so request a new line number
}
else
{
gint x_offset = 0;
// maybe we need to force a line break because of too long line
if (x >= (width - dinfo->font_width))
{
// don't start the line at horizontal origin because we need to skip the
// line number margin
if (printing_prefs.print_line_numbers)
{
x_offset = (dinfo->max_line_number_margin + 1) * dinfo->font_width;
}
//~ pango_layout_get_size(dinfo->layout, NULL, &layout_h);
//~ cairo_move_to(cr, x_offset, y + (gdouble)layout_h / PANGO_SCALE);
// this is faster but not exactly the same as above
cairo_move_to(cr, x_offset, y + dinfo->line_height);
cairo_get_current_point(cr, &x, &y);
count++;
}
if (count < dinfo->lines_per_page)
{
// str->len is counted in bytes not characters, so use g_utf8_strlen()
x_offset = (g_utf8_strlen(str->str, -1) * dinfo->font_width);
if (dinfo->long_line && count == 0)
{
x_offset = (dinfo->max_line_number_margin + 1) * dinfo->font_width;
dinfo->long_line = FALSE;
}
pango_cairo_show_layout(cr, dinfo->layout);
cairo_move_to(cr, x + x_offset, y);
}
else
// we are on a wrapped line but we are out of lines on this page, so continue
// the current line on the next page and remember to continue in current line
dinfo->long_line = TRUE;
}
}
}
if (printing_prefs.print_line_numbers)
{ // print a thin line between the line number margin and the data
gint y_start = 0;
if (printing_prefs.print_page_header)
y_start = (dinfo->line_height * 3) - 2; // "- 2": to connect the line number line to
// the page header frame
cairo_set_line_width(cr, 0.3);
cairo_move_to(cr, (dinfo->max_line_number_margin * dinfo->font_width) + 1, y_start);
cairo_line_to(cr, (dinfo->max_line_number_margin * dinfo->font_width) + 1,
y + dinfo->line_height); // y is last added line, we reuse it
cairo_stroke(cr);
}
if (printing_prefs.print_page_numbers)
{
gchar *line = g_strdup_printf("<small>- %d -</small>", page_nr + 1);
pango_layout_set_markup(dinfo->layout, line, -1);
pango_layout_set_alignment(dinfo->layout, PANGO_ALIGN_CENTER);
cairo_move_to(cr, 0, height - dinfo->line_height);
pango_cairo_show_layout(cr, dinfo->layout);
g_free(line);
#ifdef GEANY_PRINT_DEBUG
cairo_set_line_width(cr, 0.3);
cairo_move_to(cr, 0, height - (1.25 * dinfo->line_height));
cairo_line_to(cr, width - 1, height - (1.25 * dinfo->line_height));
cairo_stroke(cr);
#endif
}
g_string_free(str, TRUE);
}
static void printing_print_gtk(gint idx)
{
GtkPrintOperation *op;
GtkPrintOperationResult res = GTK_PRINT_OPERATION_RESULT_ERROR;
GError *error = NULL;
DocInfo *dinfo;
PrintWidgets *widgets;
/// TODO check for monospace font, detect the widest character in the font and use it at font_width
widgets = g_new0(PrintWidgets, 1);
dinfo = g_new0(DocInfo, 1);
// all other fields are initialised in begin_print()
dinfo->idx = idx;
op = gtk_print_operation_new();
gtk_print_operation_set_unit(op, GTK_UNIT_POINTS);
g_signal_connect(op, "begin-print", G_CALLBACK(begin_print), dinfo);
g_signal_connect(op, "end-print", G_CALLBACK(end_print), dinfo);
g_signal_connect(op, "draw-page", G_CALLBACK(draw_page), dinfo);
g_signal_connect(op, "create-custom-widget", G_CALLBACK(create_custom_widget), widgets);
g_signal_connect(op, "custom-widget-apply", G_CALLBACK(custom_widget_apply), widgets);
if (settings != NULL)
gtk_print_operation_set_print_settings(op, settings);
if (page_setup != NULL)
gtk_print_operation_set_default_page_setup(op, page_setup);
res = gtk_print_operation_run(
op, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, GTK_WINDOW(app->window), &error);
if (res == GTK_PRINT_OPERATION_RESULT_APPLY)
{
if (settings != NULL)
g_object_unref(settings);
settings = g_object_ref(gtk_print_operation_get_print_settings(op));
msgwin_status_add(_("File %s printed."), doc_list[idx].file_name);
}
else if (res == GTK_PRINT_OPERATION_RESULT_ERROR)
{
dialogs_show_msgbox(GTK_MESSAGE_ERROR, _("Printing of \"%s\" failed (%s)."),
doc_list[idx].file_name, error->message);
g_error_free(error);
}
g_object_unref(op);
g_free(dinfo);
g_free(widgets);
}
void printing_page_setup_gtk(void)
{
GtkPageSetup *new_page_setup;
if (settings == NULL)
settings = gtk_print_settings_new();
new_page_setup = gtk_print_run_page_setup_dialog(
GTK_WINDOW(app->window), page_setup, settings);
if (page_setup != NULL)
g_object_unref(page_setup);
page_setup = new_page_setup;
}
#endif // GTK 2.10
/* simple file print using an external tool */
static void print_external(gint idx)
{
gchar *cmdline;
if (doc_list[idx].file_name == NULL)
return;
if (! NZV(printing_prefs.external_print_cmd))
{
dialogs_show_msgbox(GTK_MESSAGE_ERROR,
_("Please set a print command in the preferences dialog first"));
return;
}
cmdline = g_strdup(printing_prefs.external_print_cmd);
cmdline = utils_str_replace(cmdline, "%f", doc_list[idx].file_name);
if (dialogs_show_question(
_("The file \"%s\" will be printed with the following command:\n\n%s"),
doc_list[idx].file_name, cmdline))
{
GError *error = NULL;
#ifdef G_OS_WIN32
gchar *tmp_cmdline = g_strdup(cmdline);
#else
// /bin/sh -c emulates the system() call and makes complex commands possible
// but only needed on non-win32 systems due to the lack of win32's shell capabilities
gchar *tmp_cmdline = g_strconcat("/bin/sh -c \"", cmdline, "\"", NULL);
#endif
if (! g_spawn_command_line_async(tmp_cmdline, &error))
{
dialogs_show_msgbox(GTK_MESSAGE_ERROR, _("Printing of \"%s\" failed (return code: %s)."),
doc_list[idx].file_name, error->message);
g_error_free(error);
}
else
{
msgwin_status_add(_("File %s printed."), doc_list[idx].file_name);
}
g_free(tmp_cmdline);
}
g_free(cmdline);
}
void printing_print_doc(gint idx)
{
if (! DOC_IDX_VALID(idx))
return;
#if GTK_CHECK_VERSION(2, 10, 0)
if (gtk_check_version(2, 10, 0) == NULL && printing_prefs.use_gtk_printing)
printing_print_gtk(idx);
else
#endif
print_external(idx);
}

50
src/printing.h Normal file
View File

@ -0,0 +1,50 @@
/*
* printing.h - this file is part of Geany, a fast and lightweight IDE
*
* Copyright 2007 Enrico Tröger <enrico.troeger@uvena.de>
* Copyright 2007 Nick Treleaven <nick.treleaven@btinternet.com>
*
* 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.
*
* $Id$
*/
#ifndef GEANY_PRINTING_H
#define GEANY_PRINTING_H 1
/* General printing preferences. */
typedef struct PrintingPrefs
{
gboolean use_gtk_printing;
gboolean print_line_numbers;
gboolean print_page_numbers;
gboolean print_page_header;
gboolean page_header_basename;
gchar *page_header_datefmt;
gchar *external_print_cmd;
} PrintingPrefs;
extern PrintingPrefs printing_prefs;
#if GTK_CHECK_VERSION(2, 10, 0)
void printing_page_setup_gtk(void);
#endif
void printing_print_doc(gint idx);
#endif

View File

@ -52,7 +52,7 @@ UIWidgets ui_widgets;
static struct
{
GtkWidget *document_buttons[38]; // widgets only sensitive when there is at least one document
GtkWidget *document_buttons[39]; // widgets only sensitive when there is at least one document
}
widgets;
@ -583,6 +583,7 @@ static void init_document_widgets()
widgets.document_buttons[35] = lookup_widget(app->window, "insert_date1");
widgets.document_buttons[36] = lookup_widget(app->window, "menu_format1");
widgets.document_buttons[37] = lookup_widget(app->window, "menu_open_selected_file1");
widgets.document_buttons[38] = lookup_widget(app->window, "page_setup1");
}

View File

@ -52,6 +52,7 @@ typedef struct UIWidgets
GtkWidget *recent_files_menuitem;
GtkWidget *recent_files_menubar;
GtkWidget *recent_files_toolbar;
GtkWidget *print_page_setup;
GtkWidget *menu_insert_include_items[2];
GtkWidget *popup_goto_items[3];
GtkWidget *popup_copy_items[3];