Commit 91d5b4301c473539d268b8c9c35b9c43a3b62cf3
1 parent
7cdd4cd9
Exists in
master
and in
1 other branch
Adding property "clipboar" on v3270 widget to allow set of which
clipboard will be used.
Showing
4 changed files
with
59 additions
and
12 deletions
Show diff stats
src/clipboard/selection.c
... | ... | @@ -143,11 +143,7 @@ void v3270_update_system_clipboard(GtkWidget *widget) |
143 | 143 | } |
144 | 144 | |
145 | 145 | // Has clipboard data, inform system. |
146 | -//#ifdef DEBUG | |
147 | -// GtkClipboard * clipboard = gtk_widget_get_clipboard(widget,GDK_SELECTION_PRIMARY); | |
148 | -//#else | |
149 | - GtkClipboard * clipboard = gtk_widget_get_clipboard(widget,GDK_SELECTION_CLIPBOARD); | |
150 | -//#endif // DEBUG | |
146 | + GtkClipboard * clipboard = gtk_widget_get_clipboard(widget,terminal->selection.target); | |
151 | 147 | |
152 | 148 | // Create target list |
153 | 149 | // | ... | ... |
src/include/terminal.h
... | ... | @@ -118,6 +118,7 @@ G_BEGIN_DECLS |
118 | 118 | struct { |
119 | 119 | |
120 | 120 | int baddr; ///< @brief Selection address. |
121 | + GdkAtom target; ///< @brief A GdkAtom which identifies the clipboard to use. GDK_SELECTION_CLIPBOARD gives the default clipboard. | |
121 | 122 | V3270_SELECT_FORMAT format; ///< @brief Copy format. |
122 | 123 | GList * blocks; ///< @brief Selection blocks. |
123 | 124 | ... | ... |
src/terminal/properties.c
... | ... | @@ -45,7 +45,9 @@ |
45 | 45 | #include <v3270.h> |
46 | 46 | #include <terminal.h> |
47 | 47 | |
48 | - #define PROP_BEGIN 2 | |
48 | + #define PROP_FONT_FAMILY 2 | |
49 | + #define PROP_CLIPBOARD 3 | |
50 | + #define PROP_DYNAMIC 4 | |
49 | 51 | |
50 | 52 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
51 | 53 | |
... | ... | @@ -92,10 +94,32 @@ |
92 | 94 | |
93 | 95 | // Check for internal properties. |
94 | 96 | switch(prop_id) { |
95 | - case PROP_BEGIN: // Font-family | |
97 | + case PROP_FONT_FAMILY: // Font-family | |
96 | 98 | v3270_set_font_family(GTK_WIDGET(object), g_value_get_string(value)); |
97 | 99 | break; |
98 | 100 | |
101 | + case PROP_CLIPBOARD: // Clipboard | |
102 | + { | |
103 | + const gchar * name = g_value_get_string(value); | |
104 | + if(!*name) { | |
105 | + g_message("Setting default clipboard"); | |
106 | + window->selection.target = GDK_SELECTION_CLIPBOARD; | |
107 | + } | |
108 | + else | |
109 | + { | |
110 | + GdkAtom clipboard = gdk_atom_intern(name,TRUE); | |
111 | + if(clipboard == GDK_NONE) | |
112 | + { | |
113 | + g_warning("\"%s\" is not a valid clipboard name",name); | |
114 | + } | |
115 | + else | |
116 | + { | |
117 | + window->selection.target = clipboard; | |
118 | + } | |
119 | + } | |
120 | + } | |
121 | + break; | |
122 | + | |
99 | 123 | default: |
100 | 124 | G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); |
101 | 125 | |
... | ... | @@ -146,10 +170,14 @@ |
146 | 170 | |
147 | 171 | // Check for internal properties. |
148 | 172 | switch(prop_id) { |
149 | - case PROP_BEGIN: // Font-family | |
173 | + case PROP_FONT_FAMILY: // Font-family | |
150 | 174 | g_value_set_string(value,v3270_get_font_family(GTK_WIDGET(object))); |
151 | 175 | break; |
152 | 176 | |
177 | + case PROP_CLIPBOARD: // Clipboard | |
178 | + g_value_take_string(value,gdk_atom_name(window->selection.target)); | |
179 | + break; | |
180 | + | |
153 | 181 | default: |
154 | 182 | G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); |
155 | 183 | |
... | ... | @@ -202,9 +230,9 @@ |
202 | 230 | gobject_class->set_property = v3270_set_property; |
203 | 231 | gobject_class->get_property = v3270_get_property; |
204 | 232 | |
205 | - klass->properties.count = PROP_BEGIN; | |
206 | - | |
207 | 233 | // Setup internal properties. |
234 | + | |
235 | + // Font family | |
208 | 236 | klass->properties.font_family = g_param_spec_string( |
209 | 237 | "font_family", |
210 | 238 | "font_family", |
... | ... | @@ -215,14 +243,33 @@ |
215 | 243 | |
216 | 244 | g_object_class_install_property( |
217 | 245 | gobject_class, |
218 | - klass->properties.count++, | |
246 | + PROP_FONT_FAMILY, | |
219 | 247 | klass->properties.font_family |
220 | 248 | ); |
221 | 249 | |
250 | + // Clipboard | |
251 | + spec = g_param_spec_string( | |
252 | + "clipboard", | |
253 | + "clipboard", | |
254 | + _("Clipboard name"), | |
255 | + FALSE, | |
256 | + G_PARAM_READABLE|G_PARAM_WRITABLE | |
257 | + ); | |
258 | + | |
259 | + g_object_class_install_property( | |
260 | + gobject_class, | |
261 | + PROP_CLIPBOARD, | |
262 | + spec | |
263 | + ); | |
264 | + | |
265 | + // | |
266 | + // Create dynamic properties | |
267 | + klass->properties.count = PROP_DYNAMIC; | |
268 | + | |
269 | + | |
222 | 270 | // |
223 | 271 | // Extract properties from LIB3270 control tables |
224 | 272 | // |
225 | - | |
226 | 273 | // Extract toggle class. |
227 | 274 | klass->properties.type.toggle = klass->properties.count; |
228 | 275 | for(ix = 0; ix < LIB3270_TOGGLE_COUNT; ix++) | ... | ... |
src/terminal/widget.c
... | ... | @@ -541,6 +541,9 @@ static void v3270_init(v3270 *widget) |
541 | 541 | // Install callbacks |
542 | 542 | v3270_install_callbacks(widget); |
543 | 543 | |
544 | + // Setup clipboard. | |
545 | + widget->selection.target = GDK_SELECTION_CLIPBOARD; | |
546 | + | |
544 | 547 | // Reset timer |
545 | 548 | widget->activity.timestamp = time(0); |
546 | 549 | widget->activity.disconnect = 0; | ... | ... |