Commit c10383ec authored by sumpfralle's avatar sumpfralle

moved the font dialog to a separate plugin


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@1113 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 5abd9bb6
<?xml version="1.0"?>
<interface>
<!-- interface-requires gtk+ 2.12 -->
<!-- interface-naming-policy project-wide -->
<object class="GtkDialog" id="FontDialog">
<property name="border_width">5</property>
<property name="title" translatable="yes">Engrave text</property>
<property name="role">pycam-fonts</property>
<property name="window_position">center</property>
<property name="destroy_with_parent">True</property>
<property name="icon_name">accessories-character-map</property>
<property name="type_hint">dialog</property>
<property name="transient_for">ProjectWindow</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox8">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">4</property>
<child>
<object class="GtkLabel" id="FontDialogProperties">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;Font properties:&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="FontSelectionBox">
<property name="visible">True</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkTable" id="table6">
<property name="visible">True</property>
<property name="n_rows">2</property>
<property name="n_columns">3</property>
<property name="column_spacing">3</property>
<property name="homogeneous">True</property>
<child>
<object class="GtkHScale" id="FontSideShift">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="update_policy">delayed</property>
<property name="adjustment">FontSideSkewValue</property>
<property name="round_digits">0</property>
<property name="digits">0</property>
<property name="value_pos">bottom</property>
</object>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="FontSideSkewLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Horiz. skew</property>
</object>
</child>
<child>
<object class="GtkLabel" id="FontLineSpacingLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Line spacing</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
</packing>
</child>
<child>
<object class="GtkHScale" id="FontLineSpacing">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="update_policy">delayed</property>
<property name="adjustment">FontLineSpacingValue</property>
<property name="round_digits">2</property>
<property name="digits">2</property>
<property name="value_pos">bottom</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="FontCharacterSpacingLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Pitch</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
</packing>
</child>
<child>
<object class="GtkHScale" id="FontCharacterSpacing">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="update_policy">delayed</property>
<property name="adjustment">FontCharacterSpacingValue</property>
<property name="round_digits">2</property>
<property name="digits">2</property>
<property name="value_pos">bottom</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
</object>
<packing>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox33">
<property name="visible">True</property>
<property name="spacing">3</property>
<child>
<object class="GtkLabel" id="FontAuthorLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Font author:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="FontAuthorText">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">FontAuthor</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="padding">5</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox8">
<property name="visible">True</property>
<child>
<object class="GtkLabel" id="FontDedicationQCAD">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Thanks to the</property>
<property name="use_markup">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLinkButton" id="QCADLink">
<property name="label" translatable="yes">QCAD developers</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="relief">none</property>
<property name="uri">http://qcad.org</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="FontDedicationQCADSuffix">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">for these single-line fonts!</property>
<property name="use_markup">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox28">
<property name="visible">True</property>
<property name="spacing">3</property>
<child>
<object class="GtkLabel" id="FontExamplesLinkLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Rendered overview of all fonts:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLinkButton" id="FontExamplesLink">
<property name="label">gtk-index</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="relief">none</property>
<property name="use_stock">True</property>
<property name="uri">http://sourceforge.net/apps/mediawiki/pycam/index.php?title=EngraveFonts</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkHSeparator" id="hseparator5">
<property name="visible">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">5</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox35">
<property name="visible">True</property>
<child>
<object class="GtkLabel" id="FontDialogInputLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;Text:&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkHButtonBox" id="hbuttonbox3">
<property name="visible">True</property>
<child>
<object class="GtkRadioButton" id="FontTextAlignLeft">
<property name="label">gtk-justify-left</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_stock">True</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="FontTextAlignCenter">
<property name="label">gtk-justify-center</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_stock">True</property>
<property name="draw_indicator">True</property>
<property name="group">FontTextAlignLeft</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="FontTextAlignRight">
<property name="label">gtk-justify-right</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_stock">True</property>
<property name="draw_indicator">True</property>
<property name="group">FontTextAlignLeft</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">6</property>
</packing>
</child>
<child>
<object class="GtkViewport" id="FontDialogInputViewPort">
<property name="visible">True</property>
<property name="resize_mode">queue</property>
<child>
<object class="GtkTextView" id="FontDialogInput">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="border_width">3</property>
<property name="wrap_mode">word</property>
<property name="buffer">FontDialogInputBuffer</property>
<property name="accepts_tab">False</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">7</property>
</packing>
</child>
<child>
<object class="GtkHSeparator" id="hseparator14">
<property name="visible">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">8</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="FontDialogPreviewLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;Preview:&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">9</property>
</packing>
</child>
<child>
<object class="GtkViewport" id="FontDialogPreviewViewPort">
<property name="height_request">120</property>
<property name="visible">True</property>
<property name="border_width">3</property>
<property name="resize_mode">queue</property>
<property name="shadow_type">etched-in</property>
<child>
<object class="GtkDrawingArea" id="FontDialogPreview">
<property name="visible">True</property>
</object>
</child>
</object>
<packing>
<property name="position">10</property>
</packing>
</child>
<child internal-child="action_area">
<object class="GtkHButtonBox" id="dialog-action_area7">
<property name="visible">True</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="FontDialogCancel">
<property name="label">gtk-cancel</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<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="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>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton" id="FontDialogApply">
<property name="label">gtk-apply</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="pack_type">end</property>
<property name="position">11</property>
</packing>
</child>
</object>
</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>
</object>
<object class="GtkAdjustment" id="FontLineSpacingValue">
<property name="lower">-1</property>
<property name="upper">5</property>
<property name="step_increment">0.10000000000000001</property>
</object>
<object class="GtkAdjustment" id="FontCharacterSpacingValue">
<property name="lower">-1</property>
<property name="upper">5</property>
<property name="step_increment">0.10000000000000001</property>
</object>
<object class="GtkTextBuffer" id="FontDialogInputBuffer"/>
<object class="GtkAdjustment" id="FontSideSkewValue">
<property name="lower">-100</property>
<property name="upper">100</property>
<property name="step_increment">5</property>
</object>
<object class="GtkAction" id="ShowFontDialog">
<property name="label">_Engrave text ...</property>
<property name="short_label">_Engrave text ...</property>
<property name="stock_id">gtk-select-font</property>
</object>
</interface>
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<object class="GtkListStore" id="ModelList"> <object class="GtkListStore" id="ModelList">
<columns> <columns>
<!-- column-name id --> <!-- column-name id -->
<column type="gint"/> <column type="gulong"/>
<!-- column-name name --> <!-- column-name name -->
<column type="gchararray"/> <column type="gchararray"/>
<!-- column-name state --> <!-- column-name state -->
......
...@@ -3973,496 +3973,6 @@ Please read the description of the Server Mode (linked below) to understand the ...@@ -3973,496 +3973,6 @@ Please read the description of the Server Mode (linked below) to understand the
<object class="GtkAction" id="HelpServerMode"> <object class="GtkAction" id="HelpServerMode">
<property name="label">Server Mode</property> <property name="label">Server Mode</property>
</object> </object>
<object class="GtkDialog" id="FontDialog">
<property name="border_width">5</property>
<property name="title" translatable="yes">Engrave text</property>
<property name="role">pycam-fonts</property>
<property name="window_position">center</property>
<property name="destroy_with_parent">True</property>
<property name="icon_name">accessories-character-map</property>
<property name="type_hint">dialog</property>
<property name="transient_for">ProjectWindow</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox8">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">4</property>
<child>
<object class="GtkLabel" id="FontDialogProperties">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;Font properties:&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="FontSelectionBox">
<property name="visible">True</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkTable" id="table6">
<property name="visible">True</property>
<property name="n_rows">2</property>
<property name="n_columns">3</property>
<property name="column_spacing">3</property>
<property name="homogeneous">True</property>
<child>
<object class="GtkHScale" id="FontSideShift">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="update_policy">delayed</property>
<property name="adjustment">FontSideSkewValue</property>
<property name="digits">0</property>
<property name="value_pos">bottom</property>
</object>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="FontSideSkewLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Horiz. skew</property>
</object>
</child>
<child>
<object class="GtkLabel" id="FontLineSpacingLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Line spacing</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
</packing>
</child>
<child>
<object class="GtkHScale" id="FontLineSpacing">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="update_policy">delayed</property>
<property name="adjustment">FontLineSpacingValue</property>
<property name="digits">2</property>
<property name="value_pos">bottom</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="FontCharacterSpacingLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Pitch</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
</packing>
</child>
<child>
<object class="GtkHScale" id="FontCharacterSpacing">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="update_policy">delayed</property>
<property name="adjustment">FontCharacterSpacingValue</property>
<property name="digits">2</property>
<property name="value_pos">bottom</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
</object>
<packing>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox33">
<property name="visible">True</property>
<property name="spacing">3</property>
<child>
<object class="GtkLabel" id="FontAuthorLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Font author:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="FontAuthorText">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">FontAuthor</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="padding">5</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox8">
<property name="visible">True</property>
<child>
<object class="GtkLabel" id="FontDedicationQCAD">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Thanks to the</property>
<property name="use_markup">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLinkButton" id="QCADLink">
<property name="label" translatable="yes">QCAD developers</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="has_tooltip">True</property>
<property name="relief">none</property>
<property name="uri">http://qcad.org</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="FontDedicationQCADSuffix">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">for these single-line fonts!</property>
<property name="use_markup">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox28">
<property name="visible">True</property>
<property name="spacing">3</property>
<child>
<object class="GtkLabel" id="FontExamplesLinkLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Rendered overview of all fonts:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLinkButton" id="FontExamplesLink">
<property name="label">gtk-index</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="has_tooltip">True</property>
<property name="relief">none</property>
<property name="use_stock">True</property>
<property name="uri">http://sourceforge.net/apps/mediawiki/pycam/index.php?title=EngraveFonts</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkHSeparator" id="hseparator5">
<property name="visible">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">5</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox35">
<property name="visible">True</property>
<child>
<object class="GtkLabel" id="FontDialogInputLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;Text:&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkHButtonBox" id="hbuttonbox3">
<property name="visible">True</property>
<child>
<object class="GtkRadioButton" id="FontTextAlignLeft">
<property name="label">gtk-justify-left</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_stock">True</property>
<property name="active">True</property>
<property name="draw_indicator">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="FontTextAlignCenter">
<property name="label">gtk-justify-center</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_stock">True</property>
<property name="active">True</property>
<property name="draw_indicator">False</property>
<property name="group">FontTextAlignLeft</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="FontTextAlignRight">
<property name="label">gtk-justify-right</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_stock">True</property>
<property name="active">True</property>
<property name="draw_indicator">False</property>
<property name="group">FontTextAlignLeft</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">6</property>
</packing>
</child>
<child>
<object class="GtkViewport" id="FontDialogInputViewPort">
<property name="visible">True</property>
<property name="resize_mode">queue</property>
<child>
<object class="GtkTextView" id="FontDialogInput">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="has_focus">True</property>
<property name="border_width">3</property>
<property name="wrap_mode">word</property>
<property name="buffer">FontDialogInputBuffer</property>
<property name="accepts_tab">False</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">7</property>
</packing>
</child>
<child>
<object class="GtkHSeparator" id="hseparator14">
<property name="visible">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">8</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="FontDialogPreviewLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;Preview:&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">9</property>
</packing>
</child>
<child>
<object class="GtkViewport" id="FontDialogPreviewViewPort">
<property name="height_request">120</property>
<property name="visible">True</property>
<property name="border_width">3</property>
<property name="resize_mode">queue</property>
<property name="shadow_type">etched-in</property>
<child>
<object class="GtkDrawingArea" id="FontDialogPreview">
<property name="visible">True</property>
</object>
</child>
</object>
<packing>
<property name="position">10</property>
</packing>
</child>
<child internal-child="action_area">
<object class="GtkHButtonBox" id="dialog-action_area7">
<property name="visible">True</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="FontDialogCancel">
<property name="label">gtk-cancel</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<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>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton" id="FontDialogApply">
<property name="label">gtk-apply</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="pack_type">end</property>
<property name="position">11</property>
</packing>
</child>
</object>
</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>
</object>
<object class="GtkAdjustment" id="FontSideSkewValue">
<property name="lower">-100</property>
<property name="upper">100</property>
<property name="step_increment">5</property>
</object>
<object class="GtkAction" id="ShowFontDialog">
<property name="label">_Engrave text ...</property>
<property name="stock_id">gtk-select-font</property>
</object>
<object class="GtkTextBuffer" id="FontDialogInputBuffer"/>
<object class="GtkAction" id="ExtrasMenu"> <object class="GtkAction" id="ExtrasMenu">
<property name="label">E_xtras</property> <property name="label">E_xtras</property>
</object> </object>
...@@ -4473,18 +3983,6 @@ You can paste the result into Inkscape or other vector graphic editors.</propert ...@@ -4473,18 +3983,6 @@ You can paste the result into Inkscape or other vector graphic editors.</propert
<property name="label">Undo latest model change</property> <property name="label">Undo latest model change</property>
<property name="stock_id">gtk-undo</property> <property name="stock_id">gtk-undo</property>
</object> </object>
<object class="GtkAdjustment" id="FontCharacterSpacingValue">
<property name="value">1</property>
<property name="lower">-1</property>
<property name="upper">5</property>
<property name="step_increment">0.10000000000000001</property>
</object>
<object class="GtkAdjustment" id="FontLineSpacingValue">
<property name="value">1</property>
<property name="lower">-1</property>
<property name="upper">5</property>
<property name="step_increment">0.10000000000000001</property>
</object>
<object class="GtkAdjustment" id="NumberOfProcessesValue"> <object class="GtkAdjustment" id="NumberOfProcessesValue">
<property name="upper">1000</property> <property name="upper">1000</property>
<property name="step_increment">1</property> <property name="step_increment">1</property>
......
...@@ -36,15 +36,12 @@ from pycam.Geometry.Plane import Plane ...@@ -36,15 +36,12 @@ from pycam.Geometry.Plane import Plane
import pycam.Geometry.Path import pycam.Geometry.Path
import pycam.Utils.log import pycam.Utils.log
from pycam.Utils.locations import get_data_file_location, \ from pycam.Utils.locations import get_data_file_location, \
get_ui_file_location, get_font_dir, get_external_program_location get_ui_file_location, get_external_program_location
import pycam.Utils import pycam.Utils
from pycam.Geometry.utils import sqrt from pycam.Geometry.utils import sqrt
from pycam.Gui.OpenGLTools import ModelViewWindowGL from pycam.Gui.OpenGLTools import ModelViewWindowGL
from pycam.Geometry.Letters import TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER, \
TEXT_ALIGN_RIGHT
import pycam.Geometry.Model import pycam.Geometry.Model
from pycam.Toolpath import Bounds from pycam.Toolpath import Bounds
import pycam.Utils.FontCache
import pycam.Plugins import pycam.Plugins
from pycam import VERSION from pycam import VERSION
import pycam.Physics.ode_physics import pycam.Physics.ode_physics
...@@ -328,8 +325,6 @@ class ProjectGui(object): ...@@ -328,8 +325,6 @@ class ProjectGui(object):
def __init__(self, no_dialog=False): def __init__(self, no_dialog=False):
self.settings = EventCore() self.settings = EventCore()
self.plugin_manager = pycam.Plugins.PluginManager(core=self.settings)
self.plugin_manager.import_plugins()
self.gui_is_active = False self.gui_is_active = False
self.view3d = None self.view3d = None
# during initialization any dialog (e.g. "Unit change") is not allowed # during initialization any dialog (e.g. "Unit change") is not allowed
...@@ -337,8 +332,6 @@ class ProjectGui(object): ...@@ -337,8 +332,6 @@ class ProjectGui(object):
self.no_dialog = True self.no_dialog = True
self._batch_queue = [] self._batch_queue = []
self._undo_states = [] self._undo_states = []
self._fonts_cache = pycam.Utils.FontCache.FontCache(get_font_dir(),
core=self.settings)
self.gui = gtk.Builder() self.gui = gtk.Builder()
gtk_build_file = get_ui_file_location(GTKBUILD_FILE) gtk_build_file = get_ui_file_location(GTKBUILD_FILE)
if gtk_build_file is None: if gtk_build_file is None:
...@@ -390,7 +383,6 @@ class ProjectGui(object): ...@@ -390,7 +383,6 @@ class ProjectGui(object):
("Toggle3DView", self.toggle_3d_view, None, "<Control><Shift>v"), ("Toggle3DView", self.toggle_3d_view, None, "<Control><Shift>v"),
("ToggleLogWindow", self.toggle_log_window, None, "<Control>l"), ("ToggleLogWindow", self.toggle_log_window, None, "<Control>l"),
("ToggleProcessPoolWindow", self.toggle_process_pool_window, None, None), ("ToggleProcessPoolWindow", self.toggle_process_pool_window, None, None),
("ShowFontDialog", self.toggle_font_dialog_window, None, "<Control><Shift>t"),
("UndoButton", self._restore_undo_state, None, "<Control>z"), ("UndoButton", self._restore_undo_state, None, "<Control>z"),
("CopyModelToClipboard", self.copy_model_to_clipboard, None, "<Control>c"), ("CopyModelToClipboard", self.copy_model_to_clipboard, None, "<Control>c"),
("PasteModelFromClipboard", self.paste_model_from_clipboard, None, "<Control>v"), ("PasteModelFromClipboard", self.paste_model_from_clipboard, None, "<Control>v"),
...@@ -489,51 +481,21 @@ class ProjectGui(object): ...@@ -489,51 +481,21 @@ class ProjectGui(object):
self.gui.get_object("ProcessPoolWindowClose").connect("clicked", self.toggle_process_pool_window, False) self.gui.get_object("ProcessPoolWindowClose").connect("clicked", self.toggle_process_pool_window, False)
self.gui.get_object("ProcessPoolRefreshInterval").set_value(3) self.gui.get_object("ProcessPoolRefreshInterval").set_value(3)
self.process_pool_model = self.gui.get_object("ProcessPoolStatisticsModel") self.process_pool_model = self.gui.get_object("ProcessPoolStatisticsModel")
# "font dialog" window # menu bar
self.font_dialog_window = self.gui.get_object("FontDialog") uimanager = gtk.UIManager()
self.font_dialog_window.connect("delete-event", self.settings.set("gtk-uimanager", uimanager)
self.toggle_font_dialog_window, False) self._accel_group = uimanager.get_accel_group()
self.font_dialog_window.connect("destroy", self.settings.add_item("gtk-accel-group", lambda: self._accel_group)
self.toggle_font_dialog_window, False) for window in (self.window, self.about_window, self.preferences_window,
self.gui.get_object("FontDialogCancel").connect("clicked", self.log_window, self.process_pool_window):
self.toggle_font_dialog_window, False) window.add_accel_group(self._accel_group)
self.gui.get_object("FontDialogApply").connect("clicked",
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",
self.update_font_dialog_preview)
self.gui.get_object("FontDialogPreview").connect("expose_event",
self.update_font_dialog_preview)
for objname in ("FontSideSkewValue", "FontCharacterSpacingValue",
"FontLineSpacingValue"):
obj = self.gui.get_object(objname)
# set default value before connecting the change-handler
if objname != "FontSideSkewValue":
obj.set_value(1.0)
obj.connect("value-changed",
self.update_font_dialog_preview)
for objname in ("FontTextAlignLeft", "FontTextAlignCenter",
"FontTextAlignRight"):
self.gui.get_object(objname).connect("toggled",
self.update_font_dialog_preview)
self._font_dialog_window_visible = False
self._font_dialog_window_position = None
# set defaults # set defaults
# fallback - in case of a failure when opening a model file
model = pycam.Importers.TestModel.get_test_model()
self.settings.get("models").append(model)
self.toolpath = pycam.Toolpath.ToolpathList() self.toolpath = pycam.Toolpath.ToolpathList()
self.cutter = None self.cutter = None
self.tool_list = [] self.tool_list = []
self.process_list = [] self.process_list = []
self.bounds_list = [] self.bounds_list = []
self.task_list = [] self.task_list = []
self.font_selector = None
self._last_unit = None self._last_unit = None
self._toolpath_for_grid_data = {} self._toolpath_for_grid_data = {}
# add some dummies - to be implemented later ... # add some dummies - to be implemented later ...
...@@ -1034,13 +996,6 @@ class ProjectGui(object): ...@@ -1034,13 +996,6 @@ class ProjectGui(object):
self.status_bar = self.gui.get_object("StatusBar") self.status_bar = self.gui.get_object("StatusBar")
self.gui.get_object("StatusBarEventBox").connect("button-press-event", self.gui.get_object("StatusBarEventBox").connect("button-press-event",
self.toggle_log_window) self.toggle_log_window)
# menu bar
uimanager = gtk.UIManager()
self._accel_group = uimanager.get_accel_group()
for window in (self.window, self.about_window, self.preferences_window,
self.log_window, self.process_pool_window,
self.font_dialog_window):
window.add_accel_group(self._accel_group)
# set the icons (in different sizes) for all windows # set the icons (in different sizes) for all windows
gtk.window_set_default_icon_list(*get_icons_pixbuffers()) gtk.window_set_default_icon_list(*get_icons_pixbuffers())
# load menu data # load menu data
...@@ -1081,6 +1036,12 @@ class ProjectGui(object): ...@@ -1081,6 +1036,12 @@ class ProjectGui(object):
# load the menubar and connect functions to its items # load the menubar and connect functions to its items
self.menubar = uimanager.get_widget("/MenuBar") self.menubar = uimanager.get_widget("/MenuBar")
self.settings.register_ui("main_window", "Main", self.menubar, -100) self.settings.register_ui("main_window", "Main", self.menubar, -100)
# initialize plugins
self.plugin_manager = pycam.Plugins.PluginManager(core=self.settings)
self.plugin_manager.import_plugins()
# fallback - in case of a failure when opening a model file
model = pycam.Importers.TestModel.get_test_model()
self.settings.get("models").append(model)
# some more initialization # some more initialization
self.reset_preferences() self.reset_preferences()
self.load_preferences() self.load_preferences()
...@@ -1713,97 +1674,6 @@ class ProjectGui(object): ...@@ -1713,97 +1674,6 @@ class ProjectGui(object):
obj.set_value(default_value) obj.set_value(default_value)
self.gui.get_object("ExportEMCToolDefinition").set_sensitive(len(self.tool_list) > 0) self.gui.get_object("ExportEMCToolDefinition").set_sensitive(len(self.tool_list) > 0)
@gui_activity_guard
def toggle_font_dialog_window(self, widget=None, event=None, state=None):
# only "delete-event" uses four arguments
# TODO: unify all these "toggle" functions for different windows into one single function (including storing the position)
if state is None:
state = event
if state is None:
state = not self._font_dialog_window_visible
if state:
if self.font_selector is None:
# create it manually to ease access
font_selector = gtk.combo_box_new_text()
self.gui.get_object("FontSelectionBox").pack_start(
font_selector, expand=False, fill=False)
sorted_keys = list(self._fonts_cache.get_font_names())
sorted_keys.sort(key=lambda x: x.upper())
for name in sorted_keys:
font_selector.append_text(name)
if sorted_keys:
font_selector.set_active(0)
else:
log.warn("No single-line fonts found!")
font_selector.connect("changed",
self.update_font_dialog_preview)
font_selector.show()
self.font_selector = font_selector
if len(self._fonts_cache) > 0:
# show the dialog only if fonts are available
if self._font_dialog_window_position:
self.font_dialog_window.move(
*self._font_dialog_window_position)
self.font_dialog_window.show()
self._font_dialog_window_visible = True
else:
log.error("No fonts were found on your system. " \
+ "Please check the Log Window for details.")
else:
self._font_dialog_window_position = \
self.font_dialog_window.get_position()
self.font_dialog_window.hide()
self._font_dialog_window_visible = False
# don't close the window - just hide it (for "delete-event")
return True
def get_font_dialog_text_rendered(self):
input_field = self.gui.get_object("FontDialogInput")
text_buffer = input_field.get_buffer()
text = text_buffer.get_text(text_buffer.get_start_iter(),
text_buffer.get_end_iter())
text = unicode(text)
if text:
skew = self.gui.get_object("FontSideSkewValue").get_value()
line_space = self.gui.get_object("FontLineSpacingValue").get_value()
pitch = self.gui.get_object("FontCharacterSpacingValue").get_value()
# get the active align setting
for objname, value, justification in (
("FontTextAlignLeft", TEXT_ALIGN_LEFT, gtk.JUSTIFY_LEFT),
("FontTextAlignCenter", TEXT_ALIGN_CENTER, gtk.JUSTIFY_CENTER),
("FontTextAlignRight", TEXT_ALIGN_RIGHT, gtk.JUSTIFY_RIGHT)):
obj = self.gui.get_object(objname)
if obj.get_active():
align = value
input_field.set_justification(justification)
font_name = self.font_selector.get_active_text()
charset = self._fonts_cache.get_font(font_name)
return charset.render(text, skew=skew, line_spacing=line_space,
pitch=pitch, align=align)
else:
# empty text
return None
@gui_activity_guard
def import_from_font_dialog(self, widget=None):
self.load_model(self.get_font_dialog_text_rendered())
self.append_to_queue(self.toggle_font_dialog_window)
def export_from_font_dialog(self, widget=None):
text_model = self.get_font_dialog_text_rendered()
if text_model and (not text_model.maxx is None):
self.save_model(model=text_model, store_filename=False)
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)
text_buffer.seek(0)
text = text_buffer.read()
self._copy_text_to_clipboard(text, CLIPBOARD_TARGETS["svg"])
def update_clipboard_state(self, clipboard=None, event=None): def update_clipboard_state(self, clipboard=None, event=None):
data, importer = self._get_data_and_importer_from_clipboard() data, importer = self._get_data_and_importer_from_clipboard()
paste_button = self.gui.get_object("PasteModelFromClipboard") paste_button = self.gui.get_object("PasteModelFromClipboard")
...@@ -1862,7 +1732,7 @@ class ProjectGui(object): ...@@ -1862,7 +1732,7 @@ class ProjectGui(object):
model = importer(text_buffer, model = importer(text_buffer,
program_locations=self._get_program_locations(), program_locations=self._get_program_locations(),
unit=self.settings.get("unit"), unit=self.settings.get("unit"),
fonts_cache=self._fonts_cache, fonts_cache=self.settings.get("fonts"),
callback=progress.update) callback=progress.update)
if model: if model:
log.info("Loaded a model from clipboard") log.info("Loaded a model from clipboard")
...@@ -1873,67 +1743,6 @@ class ProjectGui(object): ...@@ -1873,67 +1743,6 @@ class ProjectGui(object):
log.warn("The clipboard does not contain suitable data") log.warn("The clipboard does not contain suitable data")
progress.finish() progress.finish()
@gui_activity_guard
def update_font_dialog_preview(self, widget=None, event=None):
if not self.font_selector:
# not initialized
return
if len(self._fonts_cache) == 0:
# empty
return
font_name = self.font_selector.get_active_text()
font = self._fonts_cache.get_font(font_name)
self.gui.get_object("FontAuthorText").set_label(
os.linesep.join(font.get_authors()))
preview_widget = self.gui.get_object("FontDialogPreview")
final_drawing_area = preview_widget.window
text_model = self.get_font_dialog_text_rendered()
# always clean the background
x, y, width, height = preview_widget.get_allocation()
drawing_area = gtk.gdk.Pixmap(final_drawing_area, width, height)
drawing_area.draw_rectangle(preview_widget.get_style().white_gc, True,
0, 0, width, height)
# carefully check if there are lines in the rendered text
if text_model and (not text_model.maxx is None) and \
(text_model.maxx > text_model.minx):
# leave a small border around the preview
border = 3
x_fac = (width - 1 - 2 * border) / \
(text_model.maxx - text_model.minx)
y_fac = (height - 1 - 2 * border) / \
(text_model.maxy - text_model.miny)
factor = min(x_fac, y_fac)
# vertically centered preview
y_offset = int((height - 2 * border - \
factor * (text_model.maxy - text_model.miny)) // 2)
gc = drawing_area.new_gc()
if text_model.minx == 0:
# left align
get_virtual_x = lambda x: int(x * factor) + border
elif text_model.maxx == 0:
# right align
get_virtual_x = lambda x: width + int(x * factor) - 1 - border
else:
# center align
get_virtual_x = lambda x: \
int(width / 2.0 + x * factor) - 1 - border
get_virtual_y = lambda y: -y_offset + \
height - int((y - text_model.miny) * factor) - 1 - border
for polygon in text_model.get_polygons():
draw_points = []
points = polygon.get_points()
if polygon.is_closed:
# add the first point again to close the polygon
points.append(points[0])
for point in points:
x = get_virtual_x(point.x)
y = get_virtual_y(point.y)
draw_points.append((x, y))
drawing_area.draw_lines(gc, draw_points)
final_gc = final_drawing_area.new_gc()
final_drawing_area.draw_drawable(final_gc, drawing_area, 0, 0, 0, 0,
-1, -1)
@gui_activity_guard @gui_activity_guard
def toggle_about_window(self, widget=None, event=None, state=None): def toggle_about_window(self, widget=None, event=None, state=None):
# only "delete-event" uses four arguments # only "delete-event" uses four arguments
...@@ -2699,7 +2508,7 @@ class ProjectGui(object): ...@@ -2699,7 +2508,7 @@ class ProjectGui(object):
if self.load_model(importer(filename, if self.load_model(importer(filename,
program_locations=self._get_program_locations(), program_locations=self._get_program_locations(),
unit=self.settings.get("unit"), unit=self.settings.get("unit"),
fonts_cache=self._fonts_cache, fonts_cache=self.settings.get("fonts"),
callback=progress.update)): callback=progress.update)):
if store_filename: if store_filename:
self.set_model_filename(filename) self.set_model_filename(filename)
......
...@@ -94,9 +94,14 @@ class Settings(object): ...@@ -94,9 +94,14 @@ class Settings(object):
def get(self, key, default=None): def get(self, key, default=None):
if self.items.has_key(key): if self.items.has_key(key):
return self.items[key][self.GET_INDEX]() try:
result = self.items[key][self.GET_INDEX]()
except TypeError, err_msg:
log.info("Failed to retrieve setting '%s': %s" % (key, err_msg))
result = None
else: else:
return default result = default
return result
def set(self, key, value): def set(self, key, value):
if not self.items.has_key(key): if not self.items.has_key(key):
......
# -*- coding: utf-8 -*-
"""
$Id$
Copyright 2011 Lars Kruse <devel@sumpfralle.de>
This file is part of PyCAM.
PyCAM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
PyCAM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with PyCAM. If not, see <http://www.gnu.org/licenses/>.
"""
import os
# imported later (on demand)
#import gtk
import pycam.Plugins
import pycam.Utils.FontCache
from pycam.Utils.locations import get_font_dir
from pycam.Geometry.Letters import TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER, \
TEXT_ALIGN_RIGHT
class Fonts(pycam.Plugins.PluginBase):
UI_FILE = "fonts.ui"
def setup(self):
self._fonts_cache = pycam.Utils.FontCache.FontCache(get_font_dir(),
core=self.core)
self.core.add_item("fonts", lambda: self._fonts_cache)
# "font dialog" window
if self.gui:
import gtk
self._gtk = gtk
self.font_dialog_window = self.gui.get_object("FontDialog")
self.font_dialog_window.connect("delete-event",
self.toggle_font_dialog_window, False)
self.font_dialog_window.connect("destroy",
self.toggle_font_dialog_window, False)
self.gui.get_object("FontDialogCancel").connect("clicked",
self.toggle_font_dialog_window, False)
self.gui.get_object("FontDialogApply").connect("clicked",
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",
self.update_font_dialog_preview)
self.gui.get_object("FontDialogPreview").connect("expose_event",
self.update_font_dialog_preview)
for objname in ("FontSideSkewValue", "FontCharacterSpacingValue",
"FontLineSpacingValue"):
obj = self.gui.get_object(objname)
# set default value before connecting the change-handler
if objname != "FontSideSkewValue":
obj.set_value(1.0)
obj.connect("value-changed",
self.update_font_dialog_preview)
for objname in ("FontTextAlignLeft", "FontTextAlignCenter",
"FontTextAlignRight"):
self.gui.get_object(objname).connect("toggled",
self.update_font_dialog_preview)
# use global key accel map
self.font_dialog_window.add_accel_group(self.core.get("gtk-accel-group"))
# menu item and shortcut
actiongroup = self._gtk.ActionGroup("fonts")
font_action = self.gui.get_object("ShowFontDialog")
font_action.connect("activate", self.toggle_font_dialog_window)
key, mod = self._gtk.accelerator_parse("<Control><Shift>t")
# TODO: move the "<pycam>" accel path somewhere else
accel_path = "<pycam>/ShowFontDialog"
font_action.set_accel_path(accel_path)
self._gtk.accel_map_change_entry(accel_path, key, mod, True)
actiongroup.add_action(font_action)
self.core.get("gtk-uimanager").insert_action_group(actiongroup, pos=-1)
# store window position
self._font_dialog_window_visible = False
self._font_dialog_window_position = None
self.font_selector = None
return True
def toggle_font_dialog_window(self, widget=None, event=None, state=None):
# only "delete-event" uses four arguments
# TODO: unify all these "toggle" functions for different windows into one single function (including storing the position)
if state is None:
state = event
if state is None:
state = not self._font_dialog_window_visible
if state:
if self.font_selector is None:
# create it manually to ease access
font_selector = self._gtk.combo_box_new_text()
self.gui.get_object("FontSelectionBox").pack_start(
font_selector, expand=False, fill=False)
sorted_keys = list(self._fonts_cache.get_font_names())
sorted_keys.sort(key=lambda x: x.upper())
for name in sorted_keys:
font_selector.append_text(name)
if sorted_keys:
font_selector.set_active(0)
else:
log.warn("No single-line fonts found!")
font_selector.connect("changed",
self.update_font_dialog_preview)
font_selector.show()
self.font_selector = font_selector
if len(self._fonts_cache) > 0:
# show the dialog only if fonts are available
if self._font_dialog_window_position:
self.font_dialog_window.move(
*self._font_dialog_window_position)
self.font_dialog_window.show()
self._font_dialog_window_visible = True
else:
log.error("No fonts were found on your system. " \
+ "Please check the Log Window for details.")
else:
self._font_dialog_window_position = \
self.font_dialog_window.get_position()
self.font_dialog_window.hide()
self._font_dialog_window_visible = False
# don't close the window - just hide it (for "delete-event")
return True
def get_font_dialog_text_rendered(self):
input_field = self.gui.get_object("FontDialogInput")
text_buffer = input_field.get_buffer()
text = text_buffer.get_text(text_buffer.get_start_iter(),
text_buffer.get_end_iter())
text = unicode(text)
if text:
skew = self.gui.get_object("FontSideSkewValue").get_value()
line_space = self.gui.get_object("FontLineSpacingValue").get_value()
pitch = self.gui.get_object("FontCharacterSpacingValue").get_value()
# get the active align setting
for objname, value, justification in (
("FontTextAlignLeft", TEXT_ALIGN_LEFT, self._gtk.JUSTIFY_LEFT),
("FontTextAlignCenter", TEXT_ALIGN_CENTER, self._gtk.JUSTIFY_CENTER),
("FontTextAlignRight", TEXT_ALIGN_RIGHT, self._gtk.JUSTIFY_RIGHT)):
obj = self.gui.get_object(objname)
if obj.get_active():
align = value
input_field.set_justification(justification)
font_name = self.font_selector.get_active_text()
charset = self._fonts_cache.get_font(font_name)
return charset.render(text, skew=skew, line_spacing=line_space,
pitch=pitch, align=align)
else:
# empty text
return None
def import_from_font_dialog(self, widget=None):
self.core.get("load_model")(self.get_font_dialog_text_rendered())
self.toggle_font_dialog_window()
def export_from_font_dialog(self, widget=None):
text_model = self.get_font_dialog_text_rendered()
if text_model and (not text_model.maxx is None):
self.save_model(model=text_model, store_filename=False)
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)
text_buffer.seek(0)
text = text_buffer.read()
self._copy_text_to_clipboard(text, CLIPBOARD_TARGETS["svg"])
def update_font_dialog_preview(self, widget=None, event=None):
if not self.font_selector:
# not initialized
return
if len(self._fonts_cache) == 0:
# empty
return
font_name = self.font_selector.get_active_text()
font = self._fonts_cache.get_font(font_name)
self.gui.get_object("FontAuthorText").set_label(
os.linesep.join(font.get_authors()))
preview_widget = self.gui.get_object("FontDialogPreview")
final_drawing_area = preview_widget.window
text_model = self.get_font_dialog_text_rendered()
# always clean the background
x, y, width, height = preview_widget.get_allocation()
drawing_area = self._gtk.gdk.Pixmap(final_drawing_area, width, height)
drawing_area.draw_rectangle(preview_widget.get_style().white_gc, True,
0, 0, width, height)
# carefully check if there are lines in the rendered text
if text_model and (not text_model.maxx is None) and \
(text_model.maxx > text_model.minx):
# leave a small border around the preview
border = 3
x_fac = (width - 1 - 2 * border) / \
(text_model.maxx - text_model.minx)
y_fac = (height - 1 - 2 * border) / \
(text_model.maxy - text_model.miny)
factor = min(x_fac, y_fac)
# vertically centered preview
y_offset = int((height - 2 * border - \
factor * (text_model.maxy - text_model.miny)) // 2)
gc = drawing_area.new_gc()
if text_model.minx == 0:
# left align
get_virtual_x = lambda x: int(x * factor) + border
elif text_model.maxx == 0:
# right align
get_virtual_x = lambda x: width + int(x * factor) - 1 - border
else:
# center align
get_virtual_x = lambda x: \
int(width / 2.0 + x * factor) - 1 - border
get_virtual_y = lambda y: -y_offset + \
height - int((y - text_model.miny) * factor) - 1 - border
for polygon in text_model.get_polygons():
draw_points = []
points = polygon.get_points()
if polygon.is_closed:
# add the first point again to close the polygon
points.append(points[0])
for point in points:
x = get_virtual_x(point.x)
y = get_virtual_y(point.y)
draw_points.append((x, y))
drawing_area.draw_lines(gc, draw_points)
final_gc = final_drawing_area.new_gc()
final_drawing_area.draw_drawable(final_gc, drawing_area, 0, 0, 0, 0,
-1, -1)
...@@ -35,6 +35,7 @@ class Models(pycam.Plugins.ListPluginBase): ...@@ -35,6 +35,7 @@ class Models(pycam.Plugins.ListPluginBase):
ATTRIBUTE_MAP = {"name": COLUMN_NAME, "visible": COLUMN_VISIBLE, ATTRIBUTE_MAP = {"name": COLUMN_NAME, "visible": COLUMN_VISIBLE,
"color": COLUMN_COLOR, "alpha": COLUMN_ALPHA} "color": COLUMN_COLOR, "alpha": COLUMN_ALPHA}
ICONS = {"visible": "visible.svg", "hidden": "visible_off.svg"} ICONS = {"visible": "visible.svg", "hidden": "visible_off.svg"}
# TODO: move this to the preferences dialog
DEFAULT_COLOR = (0.5, 0.5, 1.0, 1.0) DEFAULT_COLOR = (0.5, 0.5, 1.0, 1.0)
def setup(self): def setup(self):
......
...@@ -26,7 +26,7 @@ import pycam.Plugins ...@@ -26,7 +26,7 @@ import pycam.Plugins
class Toolpaths(pycam.Plugins.ListPluginBase): class Toolpaths(pycam.Plugins.ListPluginBase):
def setup(self): def setup(self):
self.core.add_item("toolpaths", self) self.core.add_item("toolpaths", lambda: self)
return True return True
def teardown(self): def teardown(self):
......
...@@ -99,11 +99,13 @@ class FontCache(object): ...@@ -99,11 +99,13 @@ class FontCache(object):
if self.core: if self.core:
progress = self.core.get("progress") progress = self.core.get("progress")
progress.set_multiple(len(self._unused_font_files), "Loading font") progress.set_multiple(len(self._unused_font_files), "Loading font")
else:
progress = None
while not self.is_loading_complete(): while not self.is_loading_complete():
if self.core:
progress.update_multiple()
self._load_next_file(progress=progress) self._load_next_file(progress=progress)
if self.core: if progress:
progress.update_multiple()
if progress:
progress.finish() progress.finish()
def _load_next_file(self, progress=None): def _load_next_file(self, progress=None):
...@@ -112,11 +114,11 @@ class FontCache(object): ...@@ -112,11 +114,11 @@ class FontCache(object):
filename = self._unused_font_files.pop(0) filename = self._unused_font_files.pop(0)
if progress: if progress:
callback = progress.update callback = progress.update
progress.update(text="Loading font file %s" % \
os.path.basename(filename))
else: else:
callback = None callback = None
charset = pycam.Importers.CXFImporter.import_font(filename, callback=callback) charset = pycam.Importers.CXFImporter.import_font(filename, callback=callback)
if progress:
progress.finish()
if not charset is None: if not charset is None:
for name in charset.get_names(): for name in charset.get_names():
self.fonts[name] = charset self.fonts[name] = charset
......
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