Commit 1530d08
Merge branch 'master' of gitorious.org:supplement/birdfont
Changed files (4)
modifiedbirdfont/GtkWindow.valamodifiedlibbirdfont/ClipTool.valamodifiedlibbirdfont/ImportSvg.valamodifiedmac/birdfont.sh
Diff
@@ -257,42 +257,71 @@ public class GtkWindow : Gtk.Window, NativeWindow { } } + public void dump_clipboard_content (Clipboard clipboard, SelectionData selection_data) {+ string d;+ return_if_fail (!is_null (selection_data));+ d = (string) ((!) selection_data).data;+ stdout.printf (d);+ }++ public void dump_clipboard_target (Clipboard clipboard, Atom[] atoms) {+ foreach (Atom target in atoms) {+ print ("Target: " + target.name () + "\n");+ clipboard.request_contents (target, dump_clipboard_content);+ }+ }+ + public void dump_clipboard () {+ clipboard.request_targets (dump_clipboard_target);+ }+ public string get_clipboard_data () {- SelectionData? selection_data;- Atom target;+ if (Supplement.mac) {+ string? t;+ t = clipboard.wait_for_text ();+ return (t == null) ? "" : (!) t;+ } else {+ SelectionData? selection_data;+ Atom target; - target = Atom.intern_static_string ("image/x-inkscape-svg");- selection_data = clipboard.wait_for_contents (target);- - if (is_null (selection_data) || is_null (((!) selection_data).data)) {- return "";+ target = Atom.intern_static_string ("image/x-inkscape-svg");+ selection_data = clipboard.wait_for_contents (target);+ + if (is_null (selection_data) || is_null (((!) selection_data).data)) {+ return "";+ }+ + return (string) ((!) selection_data).data; }- - return (string) ((!) selection_data).data; } public void set_inkscape_clipboard (string inkscape_clipboard_data) {- TargetEntry t = { "image/x-inkscape-svg", 0, 0 };- TargetEntry[] targets = { t };- inkscape_clipboard = inkscape_clipboard_data;- - // we can't add data to this closure because the third argument - // is owner and not private data.- clipboard.set_with_owner (targets,- - // obtain clipboard data - (clipboard, selection_data, info, owner) => {- Atom type;- uchar[] data = (uchar[])(!)((GtkWindow*)owner)->inkscape_clipboard.to_utf8 ();- type = Atom.intern_static_string ("image/x-inkscape-svg");- selection_data.set (type, 8, data);- },+ // FIXME: clipboard seems to be rather broken on Mac + if (Supplement.mac) {+ clipboard.set_text (inkscape_clipboard_data, -1);+ } else {+ TargetEntry t = { "image/x-inkscape-svg", 0, 0 };+ TargetEntry[] targets = { t };+ inkscape_clipboard = inkscape_clipboard_data; - // clear clipboard data- (clipboard, user_data) => {- },+ // we can't add data to this closure because the third argument + // is owner and not private data.+ clipboard.set_with_owner (targets, - this); + // obtain clipboard data + (clipboard, selection_data, info, owner) => {+ Atom type;+ uchar[] data = (uchar[])(!)((GtkWindow*)owner)->inkscape_clipboard.to_utf8 ();+ type = Atom.intern_static_string ("image/x-inkscape-svg");+ selection_data.set (type, 8, data);+ },+ + // clear clipboard data+ (clipboard, user_data) => {+ },+ + this); + } } public void set_clipboard (string svg) {@@ -854,7 +883,7 @@ public class GlyphCanvasArea : DrawingArea { if (e.direction == Gdk.ScrollDirection.UP) { glyph_canvas.current_display.scroll_wheel_up (e.x, e.y); } else if (e.direction == Gdk.ScrollDirection.DOWN) {- glyph_canvas.current_display.scroll_wheel_down (e.x, e.y);+ glyph_canvas.current_display.scroll_wheel_down (e.x, e.y) ; } glyph_canvas.current_display.button_release (2, e.x, e.y);@@ -61,7 +61,10 @@ public class ClipTool : Tool { ((!)destination).store_undo_state (); svg = MainWindow.native_window.get_clipboard_data ();- ImportSvg.import_svg_data (svg);+ + if (svg != "") {+ ImportSvg.import_svg_data (svg);+ } ((!)destination).update_view (); }@@ -36,8 +36,7 @@ public class ImportSvg { } public static void import_svg_data (string xml_data) {- // FIXME:- if (Supplement.win32) { + if (Supplement.win32) { string svg; string xml; xml = xml_data.replace ("id", "__");@@ -1,3 +1,3 @@ #!/bin/bash cd "${0%/*}"-./birdfont\ No newline at end of file+./birdfont