further implementation of settings dialog
This commit is contained in:
parent
a2bc980c64
commit
4c04ce3614
@ -2,6 +2,7 @@ add_custom_target(glib-resources DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/resources.c
|
||||
add_custom_command(DEPENDS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/resources.xml
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/main.glade
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/dialog.glade
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/layer-widget.glade
|
||||
OUTPUT
|
||||
${CMAKE_CURRENT_BINARY_DIR}/resources.c
|
||||
|
@ -45,11 +45,12 @@
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScale">
|
||||
<object class="GtkScale" id="dialog-scale">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="adjustment">adjustment1</property>
|
||||
<property name="round_digits">1</property>
|
||||
<property name="round_digits">0</property>
|
||||
<property name="digits">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
6
main.c
6
main.c
@ -23,6 +23,7 @@
|
||||
#include "layer-selector.h"
|
||||
#include "tree-renderer/tree-store.h"
|
||||
#include "latex-output/latex-output.h"
|
||||
#include "widgets/conv-settings-dialog.h"
|
||||
|
||||
struct open_button_data {
|
||||
GtkWindow *main_window;
|
||||
@ -168,9 +169,14 @@ static void on_convert_clicked(gpointer button, gpointer user)
|
||||
struct gds_cell *cell_to_render;
|
||||
FILE *tex_file;
|
||||
GtkWidget *dialog;
|
||||
RendererSettingsDialog *settings;
|
||||
gint res;
|
||||
char *file_name;
|
||||
|
||||
settings = renderer_settings_dialog_new(GTK_WINDOW(data->main_window));
|
||||
gtk_dialog_run(GTK_DIALOG(settings));
|
||||
gtk_widget_destroy(GTK_WIDGET(settings));
|
||||
|
||||
/* Get selected cell */
|
||||
selection = gtk_tree_view_get_selection(data->tree_view);
|
||||
if (gtk_tree_selection_get_selected(selection, &model, &iter) == FALSE)
|
||||
|
@ -19,8 +19,17 @@
|
||||
|
||||
#include "conv-settings-dialog.h"
|
||||
|
||||
struct _RendererSettingsDialog {
|
||||
GtkDialog parent;
|
||||
/* Private loot */
|
||||
GtkWidget *radio_latex; // Only Latex-radio. Other one is implicit
|
||||
GtkWidget *scale;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE(RendererSettingsDialog, renderer_settings_dialog, GTK_TYPE_DIALOG)
|
||||
|
||||
|
||||
|
||||
static void renderer_settings_dialog_class_init(RendererSettingsDialogClass *klass)
|
||||
{
|
||||
/* No special code needed. Child cells are destroyed automatically due to reference counter */
|
||||
@ -30,19 +39,37 @@ static void renderer_settings_dialog_class_init(RendererSettingsDialogClass *kla
|
||||
static void renderer_settings_dialog_init(RendererSettingsDialog *self)
|
||||
{
|
||||
GtkBuilder *builder;
|
||||
GtkBox *box;
|
||||
GtkWidget *box;
|
||||
GtkDialog *dialog;
|
||||
|
||||
|
||||
dialog = &(self->parent);
|
||||
|
||||
builder = gtk_builder_new_from_resource("/dialog.glade");
|
||||
box = GTK_BOX(gtk_builder_get_object(builder, "dialog-box"));
|
||||
box = GTK_WIDGET(gtk_builder_get_object(builder, "dialog-box"));
|
||||
self->radio_latex = GTK_WIDGET(gtk_builder_get_object(builder, "latex-radio"));
|
||||
self->scale = GTK_WIDGET(gtk_builder_get_object(builder, "dialog-scale"));
|
||||
gtk_dialog_add_buttons(dialog, "Cancel", GTK_RESPONSE_CANCEL, "OK", GTK_RESPONSE_OK, NULL);
|
||||
gtk_container_add(GTK_CONTAINER(dialog), box);
|
||||
gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(dialog)), box);
|
||||
g_object_unref(builder);
|
||||
}
|
||||
|
||||
GtkWidget *renderer_settings_dialog_new(void)
|
||||
RendererSettingsDialog *renderer_settings_dialog_new(GtkWindow *parent)
|
||||
{
|
||||
return (GtkWidget *) g_object_new(RENDERER_TYPE_SETTINGS_DIALOG, NULL);
|
||||
RendererSettingsDialog *res;
|
||||
|
||||
res = RENDERER_SETTINGS_DIALOG(g_object_new(RENDERER_TYPE_SETTINGS_DIALOG, NULL));
|
||||
if (res && parent) {
|
||||
gtk_window_set_transient_for(GTK_WINDOW(res), parent);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
void renderer_settings_dialog_set_settings(RendererSettingsDialog *dialog, struct render_settings *settings)
|
||||
{
|
||||
if (!settings)
|
||||
return;
|
||||
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);
|
||||
}
|
||||
void renderer_settings_dialog_get_settings(RendererSettingsDialog *dialog, struct render_settings *settings);
|
||||
|
@ -24,16 +24,23 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
enum output_renderer {RENDERER_LATEX_TIKZ, RENDERER_CAIROGRAPHICS};
|
||||
|
||||
G_DECLARE_FINAL_TYPE(RendererSettingsDialog, renderer_settings_dialog, RENDERER, SETTINGS_DIALOG, GtkDialog)
|
||||
|
||||
GtkWidget *renderer_settings_dialog_new(void);
|
||||
|
||||
struct _RendererSettingsDialog {
|
||||
GtkDialog parent;
|
||||
};
|
||||
RendererSettingsDialog *renderer_settings_dialog_new(GtkWindow *parent);
|
||||
|
||||
#define RENDERER_TYPE_SETTINGS_DIALOG (renderer_settings_dialog_get_type())
|
||||
|
||||
struct render_settings {
|
||||
double scale;
|
||||
enum output_renderer renderer;
|
||||
};
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
void renderer_settings_dialog_set_settings(RendererSettingsDialog *dialog, struct render_settings *settings);
|
||||
void renderer_settings_dialog_get_settings(RendererSettingsDialog *dialog, struct render_settings *settings);
|
||||
|
||||
#endif /* __CONV_SETTINGS_DIALOG_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user