Add advanced export settings for LaTeX export
This commit is contained in:
parent
3167da4648
commit
2a615367d7
@ -4,7 +4,7 @@
|
|||||||
<requires lib="gtk+" version="3.20"/>
|
<requires lib="gtk+" version="3.20"/>
|
||||||
<object class="GtkAdjustment" id="adjustment1">
|
<object class="GtkAdjustment" id="adjustment1">
|
||||||
<property name="lower">1</property>
|
<property name="lower">1</property>
|
||||||
<property name="upper">2000</property>
|
<property name="upper">3000</property>
|
||||||
<property name="value">1000</property>
|
<property name="value">1000</property>
|
||||||
<property name="step_increment">10</property>
|
<property name="step_increment">10</property>
|
||||||
<property name="page_increment">1000</property>
|
<property name="page_increment">1000</property>
|
||||||
@ -58,5 +58,33 @@
|
|||||||
<property name="position">2</property>
|
<property name="position">2</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkCheckButton" id="standalone-check">
|
||||||
|
<property name="label" translatable="yes">Configure LaTeX as standalone document</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">False</property>
|
||||||
|
<property name="draw_indicator">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">3</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkCheckButton" id="layer-check">
|
||||||
|
<property name="label" translatable="yes">Generate PDF Layers</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">False</property>
|
||||||
|
<property name="draw_indicator">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">4</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</interface>
|
</interface>
|
||||||
|
@ -188,7 +188,8 @@ static void render_cell(struct gds_cell *cell, GList *layer_infos, FILE *tex_fil
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void latex_render_cell_to_code(struct gds_cell *cell, GList *layer_infos, FILE *tex_file, double scale)
|
void latex_render_cell_to_code(struct gds_cell *cell, GList *layer_infos, FILE *tex_file, double scale,
|
||||||
|
gboolean create_pdf_layers, gboolean standalone_document)
|
||||||
{
|
{
|
||||||
GString *working_line;
|
GString *working_line;
|
||||||
|
|
||||||
@ -200,9 +201,11 @@ void latex_render_cell_to_code(struct gds_cell *cell, GList *layer_infos, FILE *
|
|||||||
working_line = g_string_new_len(NULL, LATEX_LINE_BUFFER_KB*1024);
|
working_line = g_string_new_len(NULL, LATEX_LINE_BUFFER_KB*1024);
|
||||||
|
|
||||||
/* standalone foo */
|
/* standalone foo */
|
||||||
g_string_printf(working_line, "\\newif\\iftestmode\n\\testmodefalse %% Change to true for standalone rendering\n");
|
g_string_printf(working_line, "\\newif\\iftestmode\n\\testmode%s\n",
|
||||||
|
(standalone_document ? "true" : "false"));
|
||||||
WRITEOUT_BUFFER(working_line);
|
WRITEOUT_BUFFER(working_line);
|
||||||
g_string_printf(working_line, "\\newif\\ifcreatepdflayers\n\\createpdflayersfalse %% Change to true for Embedded layers in PDF output\n");
|
g_string_printf(working_line, "\\newif\\ifcreatepdflayers\n\\createpdflayers%s\n",
|
||||||
|
(create_pdf_layers ? "true" : "false"));
|
||||||
WRITEOUT_BUFFER(working_line);
|
WRITEOUT_BUFFER(working_line);
|
||||||
g_string_printf(working_line, "\\iftestmode\n");
|
g_string_printf(working_line, "\\iftestmode\n");
|
||||||
WRITEOUT_BUFFER(working_line);
|
WRITEOUT_BUFFER(working_line);
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
#define LATEX_LINE_BUFFER_KB (10)
|
#define LATEX_LINE_BUFFER_KB (10)
|
||||||
|
|
||||||
void latex_render_cell_to_code(struct gds_cell *cell, GList *layer_infos, FILE *tex_file, double scale);
|
void latex_render_cell_to_code(struct gds_cell *cell, GList *layer_infos, FILE *tex_file, double scale,
|
||||||
|
gboolean create_pdf_layers, gboolean standalone_document);
|
||||||
|
|
||||||
#endif /* __LATEX_OUTPUT_H__ */
|
#endif /* __LATEX_OUTPUT_H__ */
|
||||||
|
3
main.c
3
main.c
@ -229,7 +229,8 @@ static void on_convert_clicked(gpointer button, gpointer user)
|
|||||||
switch (sett.renderer) {
|
switch (sett.renderer) {
|
||||||
case RENDERER_LATEX_TIKZ:
|
case RENDERER_LATEX_TIKZ:
|
||||||
output_file = fopen(file_name, "w");
|
output_file = fopen(file_name, "w");
|
||||||
latex_render_cell_to_code(cell_to_render, layer_list, output_file, sett.scale);
|
latex_render_cell_to_code(cell_to_render, layer_list, output_file, sett.scale,
|
||||||
|
sett.tex_pdf_layers, sett.tex_standalone);
|
||||||
fclose(output_file);
|
fclose(output_file);
|
||||||
break;
|
break;
|
||||||
case RENDERER_CAIROGRAPHICS:
|
case RENDERER_CAIROGRAPHICS:
|
||||||
|
@ -20,11 +20,13 @@
|
|||||||
#include "conv-settings-dialog.h"
|
#include "conv-settings-dialog.h"
|
||||||
|
|
||||||
struct _RendererSettingsDialog {
|
struct _RendererSettingsDialog {
|
||||||
GtkDialog parent;
|
GtkDialog parent;
|
||||||
/* Private loot */
|
/* Private loot */
|
||||||
GtkWidget *radio_latex;
|
GtkWidget *radio_latex;
|
||||||
GtkWidget *radio_cairo;
|
GtkWidget *radio_cairo;
|
||||||
GtkWidget *scale;
|
GtkWidget *scale;
|
||||||
|
GtkWidget *layer_check;
|
||||||
|
GtkWidget *standalone_check;
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE(RendererSettingsDialog, renderer_settings_dialog, GTK_TYPE_DIALOG)
|
G_DEFINE_TYPE(RendererSettingsDialog, renderer_settings_dialog, GTK_TYPE_DIALOG)
|
||||||
@ -37,6 +39,27 @@ static void renderer_settings_dialog_class_init(RendererSettingsDialogClass *kla
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void show_tex_options(RendererSettingsDialog *self)
|
||||||
|
{
|
||||||
|
gtk_widget_show(self->layer_check);
|
||||||
|
gtk_widget_show(self->standalone_check);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void hide_tex_options(RendererSettingsDialog *self)
|
||||||
|
{
|
||||||
|
gtk_widget_hide(self->layer_check);
|
||||||
|
gtk_widget_hide(self->standalone_check);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void latex_render_callback(GtkToggleButton *radio, RendererSettingsDialog *dialog)
|
||||||
|
{
|
||||||
|
if (gtk_toggle_button_get_active(radio))
|
||||||
|
show_tex_options(dialog);
|
||||||
|
else
|
||||||
|
hide_tex_options(dialog);
|
||||||
|
}
|
||||||
|
|
||||||
static void renderer_settings_dialog_init(RendererSettingsDialog *self)
|
static void renderer_settings_dialog_init(RendererSettingsDialog *self)
|
||||||
{
|
{
|
||||||
GtkBuilder *builder;
|
GtkBuilder *builder;
|
||||||
@ -51,10 +74,15 @@ static void renderer_settings_dialog_init(RendererSettingsDialog *self)
|
|||||||
self->radio_latex = GTK_WIDGET(gtk_builder_get_object(builder, "latex-radio"));
|
self->radio_latex = GTK_WIDGET(gtk_builder_get_object(builder, "latex-radio"));
|
||||||
self->radio_cairo = GTK_WIDGET(gtk_builder_get_object(builder, "cairo-radio"));
|
self->radio_cairo = GTK_WIDGET(gtk_builder_get_object(builder, "cairo-radio"));
|
||||||
self->scale = GTK_WIDGET(gtk_builder_get_object(builder, "dialog-scale"));
|
self->scale = GTK_WIDGET(gtk_builder_get_object(builder, "dialog-scale"));
|
||||||
|
self->standalone_check = GTK_WIDGET(gtk_builder_get_object(builder, "standalone-check"));
|
||||||
|
self->layer_check = GTK_WIDGET(gtk_builder_get_object(builder, "layer-check"));
|
||||||
|
|
||||||
gtk_dialog_add_buttons(dialog, "Cancel", GTK_RESPONSE_CANCEL, "OK", GTK_RESPONSE_OK, NULL);
|
gtk_dialog_add_buttons(dialog, "Cancel", GTK_RESPONSE_CANCEL, "OK", GTK_RESPONSE_OK, NULL);
|
||||||
gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(dialog)), box);
|
gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(dialog)), box);
|
||||||
gtk_window_set_title(GTK_WINDOW(self), "Renderer Settings");
|
gtk_window_set_title(GTK_WINDOW(self), "Renderer Settings");
|
||||||
|
|
||||||
|
g_signal_connect(self->radio_latex, "toggled", G_CALLBACK(latex_render_callback), (gpointer)self);
|
||||||
|
|
||||||
g_object_unref(builder);
|
g_object_unref(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,18 +103,25 @@ void renderer_settings_dialog_get_settings(RendererSettingsDialog *dialog, struc
|
|||||||
return;
|
return;
|
||||||
settings->scale = gtk_range_get_value(GTK_RANGE(dialog->scale));
|
settings->scale = gtk_range_get_value(GTK_RANGE(dialog->scale));
|
||||||
settings->renderer = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->radio_latex)) == TRUE ? RENDERER_LATEX_TIKZ : RENDERER_CAIROGRAPHICS);
|
settings->renderer = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->radio_latex)) == TRUE ? RENDERER_LATEX_TIKZ : RENDERER_CAIROGRAPHICS);
|
||||||
|
settings->tex_pdf_layers = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->layer_check));
|
||||||
|
settings->tex_standalone = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->standalone_check));
|
||||||
}
|
}
|
||||||
void renderer_settings_dialog_set_settings(RendererSettingsDialog *dialog, struct render_settings *settings)
|
void renderer_settings_dialog_set_settings(RendererSettingsDialog *dialog, struct render_settings *settings)
|
||||||
{
|
{
|
||||||
if (!settings || !dialog)
|
if (!settings || !dialog)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gtk_range_set_value(GTK_RANGE(dialog->scale), settings->scale);
|
gtk_range_set_value(GTK_RANGE(dialog->scale), settings->scale);
|
||||||
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->layer_check), settings->tex_pdf_layers);
|
||||||
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->standalone_check), settings->tex_standalone);
|
||||||
|
|
||||||
switch (settings->renderer) {
|
switch (settings->renderer) {
|
||||||
case RENDERER_LATEX_TIKZ:
|
case RENDERER_LATEX_TIKZ:
|
||||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->radio_latex), TRUE);
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->radio_latex), TRUE);
|
||||||
|
show_tex_options(dialog);
|
||||||
break;
|
break;
|
||||||
case RENDERER_CAIROGRAPHICS:
|
case RENDERER_CAIROGRAPHICS:
|
||||||
|
hide_tex_options(dialog);
|
||||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->radio_cairo), TRUE);
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->radio_cairo), TRUE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,8 @@ RendererSettingsDialog *renderer_settings_dialog_new(GtkWindow *parent);
|
|||||||
struct render_settings {
|
struct render_settings {
|
||||||
double scale;
|
double scale;
|
||||||
enum output_renderer renderer;
|
enum output_renderer renderer;
|
||||||
|
gboolean tex_pdf_layers;
|
||||||
|
gboolean tex_standalone;
|
||||||
};
|
};
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
Loading…
Reference in New Issue
Block a user