File: chapter-clipboard.html

package info (click to toggle)
gtkmm-documentation 4.12.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 25,772 kB
  • sloc: cpp: 15,541; javascript: 1,208; makefile: 1,080; python: 401; xml: 106; perl: 67; sh: 8
file content (117 lines) | stat: -rw-r--r-- 5,001 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="highlight.min.css">
<script src="highlight.min.js"></script><script>
      hljs.configure({languages: ['cpp']});
      hljs.highlightAll();
    </script><title>Chapter 20. The Clipboard</title>
<link rel="stylesheet" type="text/css" href="style.css">
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="index.html" title="Programming with gtkmm 4">
<link rel="up" href="index.html" title="Programming with gtkmm 4">
<link rel="prev" href="sec-dnd-example.html" title="Example">
<link rel="next" href="sec-clipboard-copy.html" title="Copy">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="navheader">
<table width="100%" summary="Navigation header">
<tr><th colspan="3" align="center">Chapter 20. The Clipboard</th></tr>
<tr>
<td width="20%" align="left">
<a accesskey="p" href="sec-dnd-example.html"><img src="icons/prev.png" alt="Prev"></a> </td>
<th width="60%" align="center"> </th>
<td width="20%" align="right"> <a accesskey="n" href="sec-clipboard-copy.html"><img src="icons/next.png" alt="Next"></a>
</td>
</tr>
</table>
<hr>
</div>
<div class="chapter">
<div class="titlepage"><div><div><h1 class="title">
<a name="chapter-clipboard"></a>Chapter 20. The Clipboard</h1></div></div></div>
<div class="toc">
<p><b>Table of Contents</b></p>
<ul class="toc">
<li><span class="section"><a href="chapter-clipboard.html#sec-clipboard-formats">Formats</a></span></li>
<li><span class="section"><a href="sec-clipboard-copy.html">Copy</a></span></li>
<li><span class="section"><a href="sec-clipboard-paste.html">Paste</a></span></li>
<li><span class="section"><a href="sec-clipboard-examples.html">Examples</a></span></li>
</ul>
</div>


<p>Simple text copy-paste functionality is provided for free by widgets such as
<code class="classname">Gtk::Entry</code> and <code class="classname">Gtk::TextView</code>,
but you might need special code to deal with your own data formats. For instance,
a drawing program would need special code to allow copy and paste within a view,
or between documents.</p>

<p>
You can get a clipboard instance with <code class="methodname">Gtk::Widget::get_clipboard()</code>
or <code class="methodname">Gdk::Display::get_clipboard()</code>.
</p>

<p>
Your application doesn't need to wait for clipboard operations, particularly
between the time when the user chooses Copy and then later chooses Paste. Many
<code class="classname">Gdk::Clipboard</code> methods take <code class="classname">sigc::slot</code>s
which specify callback methods. When <code class="classname">Gdk::Clipboard</code> is ready,
it will call these methods, providing the requested data.
</p>

<p><a class="ulink" href="https://gnome.pages.gitlab.gnome.org/gtkmm/classGdk_1_1Clipboard.html" target="_top">Reference</a></p>

<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="sec-clipboard-formats"></a>Formats</h2></div></div></div>


<p>
Different applications contain different types of data, and they might make that data available in
a variety of formats. <span class="application">gtkmm</span> calls these data types <code class="literal">format</code>s.</p>

<p>
For instance, <span class="application">gedit</span> can supply and receive the <code class="literal">text/plain</code> mime type,
so you can paste data into <span class="application">gedit</span> from any application that supplies that format.
Or two different image editing applications might supply and receive a variety of image formats.
As long as one application can receive one of the formats that the other supplies
then you will be able to copy data from one to the other.
</p>

<p>
Clipboard data can be in a variety of binary formats. This chapter, and the examples,
assume that the data is 8-bit text. This would allow us to use an XML format
for the clipboard data. However this would probably not be appropriate for
binary data such as images.
</p>

<p>The <a class="link" href="chapter-draganddrop.html" title="Chapter 19. Drag and Drop">Drag and Drop</a> API uses the same mechanism.
You should probably use the same data formats for both Clipboard and Drag and Drop operations.</p>
</div>






</div>
<div class="navfooter">
<hr>
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left">
<a accesskey="p" href="sec-dnd-example.html"><img src="icons/prev.png" alt="Prev"></a> </td>
<td width="20%" align="center"> </td>
<td width="40%" align="right"> <a accesskey="n" href="sec-clipboard-copy.html"><img src="icons/next.png" alt="Next"></a>
</td>
</tr>
<tr>
<td width="40%" align="left" valign="top">Example </td>
<td width="20%" align="center"><a accesskey="h" href="index.html"><img src="icons/home.png" alt="Home"></a></td>
<td width="40%" align="right" valign="top"> Copy</td>
</tr>
</table>
</div>
</body>
</html>