Commit 4d6ecc31 authored by sumpfralle's avatar sumpfralle

added "copy to clipboard" for rendered text (as SVG)


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@996 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 8f3615ad
......@@ -7923,6 +7923,22 @@ Please read the description of the Server Mode (linked below) to understand the
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="FontDialogCopy">
<property name="label">gtk-copy</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Copy the current model to the clipboard (as SVG data).
You can paste the result into Inkscape or other vector graphic editors.</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="FontDialogSave">
<property name="label">Save as SVG</property>
......@@ -7933,7 +7949,7 @@ Please read the description of the Server Mode (linked below) to understand the
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
<property name="position">2</property>
</packing>
</child>
<child>
......@@ -7947,7 +7963,7 @@ Please read the description of the Server Mode (linked below) to understand the
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
<property name="position">3</property>
</packing>
</child>
</object>
......@@ -7961,6 +7977,7 @@ Please read the description of the Server Mode (linked below) to understand the
</child>
<action-widgets>
<action-widget response="0">FontDialogCancel</action-widget>
<action-widget response="0">FontDialogCopy</action-widget>
<action-widget response="0">FontDialogSave</action-widget>
<action-widget response="0">FontDialogApply</action-widget>
</action-widgets>
......
......@@ -416,6 +416,8 @@ class ProjectGui:
self.import_from_font_dialog)
self.gui.get_object("FontDialogSave").connect("clicked",
self.export_from_font_dialog)
self.gui.get_object("FontDialogCopy").connect("clicked",
self.copy_font_dialog_to_clipboard)
self.gui.get_object("FontDialogInputBuffer").connect("changed",
self.update_font_dialog_preview)
self.gui.get_object("FontDialogPreview").connect("configure_event",
......@@ -1899,6 +1901,22 @@ class ProjectGui:
if text_model and (not text_model.maxx is None):
self.save_model(model=text_model)
def copy_font_dialog_to_clipboard(self, widget=None):
text_model = self.get_font_dialog_text_rendered()
if text_model and (not text_model.maxx is None):
text_buffer = StringIO.StringIO()
text_model.export(comment=self.get_meta_data(),
unit=self.settings.get("unit")).write(text_buffer)
clipboard_target = "image/svg+xml"
clipboard = gtk.clipboard_get()
targets = [(clipboard_target, gtk.TARGET_OTHER_WIDGET, 0)]
def get_func(clipboard, selectiondata, info, text):
text.seek(0)
selectiondata.set("STRING", 8, text.read())
result = clipboard.set_with_data(targets, get_func,
lambda *args: None, text_buffer)
clipboard.store()
@gui_activity_guard
def update_font_dialog_preview(self, widget=None, event=None):
if not self._fonts:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment