/* * Copyright (C) 2004-2005 Vadim Berezniker * http://www.kryptolus.com * * This Program 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 2, or (at your option) * any later version. * * This Program 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 GNU Make; see the file COPYING. If not, write to * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * http://www.gnu.org/copyleft/gpl.html * */ #include "stdafx.h" #include "common.h" #include "sabbu.h" #include "gui_export.h" #include "gui_export_text.h" extern struct sabbu app; void gui_export_text_check_cb(GtkToggleButton *widget, gboolean *val) { *val = gtk_toggle_button_get_active(widget); } struct export_settings_text *gui_export_text_show() { GtkDialog *dialog = GTK_DIALOG(gtk_dialog_new_with_buttons(_("Text Export Settings"), app.ui.window, GTK_DIALOG_MODAL, GTK_STOCK_OK, GTK_RESPONSE_OK, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL)); GtkVBox *vbox = GTK_VBOX(gtk_vbox_new(FALSE, 0)); struct export_settings_text *settings = kry_new0(struct export_settings_text); app.prefs->PushSection("ExportText"); { GtkFrame *frame_options = GTK_FRAME(gtk_frame_new(_("Export Options"))); GtkVBox *vbox_options = GTK_VBOX(gtk_vbox_new(FALSE, 0)); GtkCheckButton *button_script_properties = GTK_CHECK_BUTTON(gtk_check_button_new_with_label(__("ExportText|Script Properties"))); GtkCheckButton *button_comments = GTK_CHECK_BUTTON(gtk_check_button_new_with_label(__("ExportText|Comments"))); GtkCheckButton *button_double_space = GTK_CHECK_BUTTON(gtk_check_button_new_with_label(__("ExportText|ExportText|Double Spaced"))); GtkCheckButton *button_comma = GTK_CHECK_BUTTON(gtk_check_button_new_with_label(__("ExportText|ExportText|Save as Comma Separated Values (CSV)"))); g_signal_connect(G_OBJECT(button_script_properties), "toggled", G_CALLBACK(gui_export_text_check_cb), &settings->script_properties); g_signal_connect(G_OBJECT(button_comments), "toggled", G_CALLBACK(gui_export_text_check_cb), &settings->comments); g_signal_connect(G_OBJECT(button_double_space), "toggled", G_CALLBACK(gui_export_text_check_cb), &settings->double_space); g_signal_connect(G_OBJECT(button_comma), "toggled", G_CALLBACK(gui_export_text_check_cb), &settings->use_comma); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button_script_properties), app.prefs->GetInt("ScriptProperties", 1)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button_comments), app.prefs->GetInt("Comments", 1)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button_double_space), app.prefs->GetInt("DoubleSpace", 0)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button_comma), app.prefs->GetInt("UseComma", 0)); gtk_box_pack_start(GTK_BOX(vbox_options), GTK_WIDGET(button_script_properties), FALSE, TRUE, 2); gtk_box_pack_start(GTK_BOX(vbox_options), GTK_WIDGET(button_comments), FALSE, TRUE, 2); gtk_box_pack_start(GTK_BOX(vbox_options), GTK_WIDGET(button_double_space), FALSE, TRUE, 2); gtk_box_pack_start(GTK_BOX(vbox_options), GTK_WIDGET(button_comma), FALSE, TRUE, 2); gtk_container_add(GTK_CONTAINER(frame_options), GTK_WIDGET(vbox_options)); gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(frame_options), FALSE, TRUE, 0); } { GtkFrame *frame_options = GTK_FRAME(gtk_frame_new(_("Export Columns"))); GtkVBox *vbox_options = GTK_VBOX(gtk_vbox_new(FALSE, 0)); GtkCheckButton *button_column_start = GTK_CHECK_BUTTON(gtk_check_button_new_with_label(__("ExportText|Start Time"))); GtkCheckButton *button_column_end = GTK_CHECK_BUTTON(gtk_check_button_new_with_label(__("ExportText|End Time"))); GtkCheckButton *button_column_style = GTK_CHECK_BUTTON(gtk_check_button_new_with_label(__("ExportText|Style"))); GtkCheckButton *button_column_name = GTK_CHECK_BUTTON(gtk_check_button_new_with_label(__("ExportText|Name"))); GtkCheckButton *button_column_text = GTK_CHECK_BUTTON(gtk_check_button_new_with_label(__("ExportText|Text"))); g_signal_connect(G_OBJECT(button_column_start), "toggled", G_CALLBACK(gui_export_text_check_cb), &settings->column_start); g_signal_connect(G_OBJECT(button_column_end), "toggled", G_CALLBACK(gui_export_text_check_cb), &settings->column_end); g_signal_connect(G_OBJECT(button_column_style), "toggled", G_CALLBACK(gui_export_text_check_cb), &settings->column_style); g_signal_connect(G_OBJECT(button_column_name), "toggled", G_CALLBACK(gui_export_text_check_cb), &settings->column_name); g_signal_connect(G_OBJECT(button_column_text), "toggled", G_CALLBACK(gui_export_text_check_cb), &settings->column_text); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button_column_start), app.prefs->GetInt("ColumnStart", 0)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button_column_end), app.prefs->GetInt("ColumnEnd", 0)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button_column_style), app.prefs->GetInt("ColumnStyle", 0)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button_column_name), app.prefs->GetInt("ColumnName", 1)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button_column_text), app.prefs->GetInt("ColumnText", 1)); gtk_box_pack_start(GTK_BOX(vbox_options), GTK_WIDGET(button_column_start), FALSE, TRUE, 2); gtk_box_pack_start(GTK_BOX(vbox_options), GTK_WIDGET(button_column_end), FALSE, TRUE, 2); gtk_box_pack_start(GTK_BOX(vbox_options), GTK_WIDGET(button_column_style), FALSE, TRUE, 2); gtk_box_pack_start(GTK_BOX(vbox_options), GTK_WIDGET(button_column_name), FALSE, TRUE, 2); gtk_box_pack_start(GTK_BOX(vbox_options), GTK_WIDGET(button_column_text), FALSE, TRUE, 2); gtk_container_add(GTK_CONTAINER(frame_options), GTK_WIDGET(vbox_options)); gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(frame_options), FALSE, TRUE, 0); } gtk_box_pack_start(GTK_BOX(vbox), gui_export_format_options_create_ui(&settings->settings), FALSE, TRUE, 0); gtk_box_pack_start(GTK_BOX(dialog->vbox), GTK_WIDGET(vbox), FALSE, TRUE, 2); gtk_widget_show_all(GTK_WIDGET(dialog)); int rv = gtk_dialog_run(dialog); if(rv == GTK_RESPONSE_OK) { app.prefs->SetInt("ScriptProperties", settings->script_properties); app.prefs->SetInt("Comments", settings->comments); app.prefs->SetInt("UseComma", settings->use_comma); app.prefs->SetInt("DoubleSpace", settings->double_space); app.prefs->SetInt("ColumnStart", settings->column_start); app.prefs->SetInt("ColumnEnd", settings->column_end); app.prefs->SetInt("ColumnStyle", settings->column_style); app.prefs->SetInt("ColumnName", settings->column_name); app.prefs->SetInt("ColumnText", settings->column_text); gui_export_format_options_save(&settings->settings); } else { kry_free(settings); settings = NULL; } app.prefs->PopSection(); gui_main_focus(); gtk_widget_destroy(GTK_WIDGET(dialog)); return settings; }