📄 gtk-high-level-printing-api.html
字号:
<a class="link" href="gtk-GtkPaperSize.html#GtkUnit">GtkUnit</a> unit);</pre><p>Sets up the transformation for the cairo context obtained from<a class="link" href="GtkPrintContext.html" title="GtkPrintContext"><span class="type">GtkPrintContext</span></a> in such a way that distances are measured in units of <em class="parameter"><code>unit</code></em>.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>op</code></em> :</span></p></td><td> a <a class="link" href="gtk-High-level-Printing-API.html#GtkPrintOperation"><span class="type">GtkPrintOperation</span></a></td></tr><tr><td><p><span class="term"><em class="parameter"><code>unit</code></em> :</span></p></td><td> the unit to use</td></tr></tbody></table></div><p class="since">Since 2.10</p></div><hr><div class="refsect2" lang="en"><a name="id4131584"></a><h3><a name="gtk-print-operation-set-export-filename"></a>gtk_print_operation_set_export_filename ()</h3><a class="indexterm" name="id4131601"></a><pre class="programlisting">void gtk_print_operation_set_export_filename (<a class="link" href="gtk-High-level-Printing-API.html#GtkPrintOperation">GtkPrintOperation</a> *op, const <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a> *filename);</pre><p>Sets up the <a class="link" href="gtk-High-level-Printing-API.html#GtkPrintOperation"><span class="type">GtkPrintOperation</span></a> to generate a file insteadof showing the print dialog. The indended use of this functionis for implementing "Export to PDF" actions. Currently, PDFis the only supported format.</p><p>"Print to PDF" support is independent of this and is doneby letting the user pick the "Print to PDF" item from the listof printers in the print dialog.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>op</code></em> :</span></p></td><td> a <a class="link" href="gtk-High-level-Printing-API.html#GtkPrintOperation"><span class="type">GtkPrintOperation</span></a></td></tr><tr><td><p><span class="term"><em class="parameter"><code>filename</code></em> :</span></p></td><td> the filename for the exported file</td></tr></tbody></table></div><p class="since">Since 2.10</p></div><hr><div class="refsect2" lang="en"><a name="id4131707"></a><h3><a name="gtk-print-operation-set-show-progress"></a>gtk_print_operation_set_show_progress ()</h3><a class="indexterm" name="id4131723"></a><pre class="programlisting">void gtk_print_operation_set_show_progress (<a class="link" href="gtk-High-level-Printing-API.html#GtkPrintOperation">GtkPrintOperation</a> *op, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> show_progress);</pre><p>If <em class="parameter"><code>show_progress</code></em> is <ahref="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>, the print operation will show a progress dialog during the print operation.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>op</code></em> :</span></p></td><td> a <a class="link" href="gtk-High-level-Printing-API.html#GtkPrintOperation"><span class="type">GtkPrintOperation</span></a></td></tr><tr><td><p><span class="term"><em class="parameter"><code>show_progress</code></em> :</span></p></td><td> <ahref="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> to show a progress dialog</td></tr></tbody></table></div><p class="since">Since 2.10</p></div><hr><div class="refsect2" lang="en"><a name="id4131839"></a><h3><a name="gtk-print-operation-set-track-print-status"></a>gtk_print_operation_set_track_print_status ()</h3><a class="indexterm" name="id4131856"></a><pre class="programlisting">void gtk_print_operation_set_track_print_status (<a class="link" href="gtk-High-level-Printing-API.html#GtkPrintOperation">GtkPrintOperation</a> *op, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> track_status);</pre><p>If track_status is <ahref="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>, the print operation will try to continue reporton the status of the print job in the printer queues and printer. Thiscan allow your application to show things like "out of paper" issues,and when the print job actually reaches the printer.</p><p>This function is often implemented using some form of polling, so it shouldnot be enabled unless needed.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>op</code></em> :</span></p></td><td> a <a class="link" href="gtk-High-level-Printing-API.html#GtkPrintOperation"><span class="type">GtkPrintOperation</span></a></td></tr><tr><td><p><span class="term"><em class="parameter"><code>track_status</code></em> :</span></p></td><td> <ahref="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> to track status after printing</td></tr></tbody></table></div><p class="since">Since 2.10</p></div><hr><div class="refsect2" lang="en"><a name="id4131974"></a><h3><a name="gtk-print-operation-set-custom-tab-label"></a>gtk_print_operation_set_custom_tab_label ()</h3><a class="indexterm" name="id4131990"></a><pre class="programlisting">void gtk_print_operation_set_custom_tab_label (<a class="link" href="gtk-High-level-Printing-API.html#GtkPrintOperation">GtkPrintOperation</a> *op, const <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a> *label);</pre><p>Sets the label for the tab holding custom widgets.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>op</code></em> :</span></p></td><td> a <a class="link" href="gtk-High-level-Printing-API.html#GtkPrintOperation"><span class="type">GtkPrintOperation</span></a></td></tr><tr><td><p><span class="term"><em class="parameter"><code>label</code></em> :</span></p></td><td> the label to use, or <ahref="/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL:CAPS"><code class="literal">NULL</code></a> to use the default label</td></tr></tbody></table></div><p class="since">Since 2.10</p></div><hr><div class="refsect2" lang="en"><a name="id4132090"></a><h3><a name="gtk-print-operation-run"></a>gtk_print_operation_run ()</h3><a class="indexterm" name="id4132105"></a><pre class="programlisting"><a class="link" href="gtk-High-level-Printing-API.html#GtkPrintOperationResult">GtkPrintOperationResult</a> gtk_print_operation_run (<a class="link" href="gtk-High-level-Printing-API.html#GtkPrintOperation">GtkPrintOperation</a> *op, <a class="link" href="gtk-High-level-Printing-API.html#GtkPrintOperationAction">GtkPrintOperationAction</a> action, <a class="link" href="GtkWindow.html" title="GtkWindow">GtkWindow</a> *parent, <ahref="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError">GError</a> **error);</pre><p>Runs the print operation, by first letting the user modifyprint settings in the print dialog, and then print the document.</p><p>Normally that this function does not return until the rendering of all pages is complete. You can connect to the <a class="link" href="gtk-High-level-Printing-API.html#GtkPrintOperation-status-changed"><span class="type">"status-changed"</span></a> signal on <em class="parameter"><code>op</code></em> to obtain some information about the progress of the print operation. Furthermore, it may use a recursive mainloop to show the print dialog.</p><p>If you call <a class="link" href="gtk-High-level-Printing-API.html#gtk-print-operation-set-allow-async"><code class="function">gtk_print_operation_set_allow_async()</code></a> or set the allow-asyncproperty the operation will run asyncronously if this is supported on theplatform. The <a class="link" href="gtk-High-level-Printing-API.html#GtkPrintOperation-done"><span class="type">"done"</span></a> signal will be emitted with the operation results when the operation is done (i.e. when the dialog is canceled, or when the print succeeds or fails).</p><p></p><div class="informalexample"><pre class="programlisting">if (settings != NULL) gtk_print_operation_set_print_settings (print, settings); if (page_setup != NULL) gtk_print_operation_set_default_page_setup (print, page_setup); g_signal_connect (print, "begin-print", G_CALLBACK (begin_print), &data);g_signal_connect (print, "draw-page", G_CALLBACK (draw_page), &data); res = gtk_print_operation_run (print, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, parent, &error); if (res == GTK_PRINT_OPERATION_RESULT_ERROR) { error_dialog = gtk_message_dialog_new (GTK_WINDOW (parent), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "Error printing file:\n%s", error->message); g_signal_connect (error_dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL); gtk_widget_show (error_dialog); g_error_free (error); }else if (res == GTK_PRINT_OPERATION_RESULT_APPLY) { if (settings != NULL)g_object_unref (settings); settings = g_object_ref (gtk_print_operation_get_print_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -