/*
  Cloned Xunzip
  Copyright (C) 1999 Tero Koskinen

  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 of the License, 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 this program; if not, write to the Free Software
  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
*/

#include <stdio.h>
#include <config.h>

#include <gnome.h>

#include <string>

#include "app.hh"
#include "prefs.hh"
#include "callbacks.hh"
#include "uncompresswindow.hh"

void create_uncompress_dialog(App *app)
{
	GSList *buttonGroup;
	GtkWidget *label;
	GtkWidget *lcaseNamesButton;
	GtkWidget *rButton1;
	GtkWidget *rButton2;

	g_return_if_fail(app!=NULL);
	
	if (app->zip->opened==0)
		return;
	
	if (app->dialog==0) {
		app->dialog=gnome_dialog_new(_("Uncompress archive"),
					     GNOME_STOCK_BUTTON_OK,
					     GNOME_STOCK_BUTTON_CANCEL,NULL);
		gnome_dialog_set_close(GNOME_DIALOG(app->dialog),FALSE);
		
		gnome_dialog_button_connect(GNOME_DIALOG(app->dialog),0,
					    GTK_SIGNAL_FUNC(dialog_uncompress_callback),
					    app);
		gnome_dialog_button_connect(GNOME_DIALOG(app->dialog),1,
					    GTK_SIGNAL_FUNC(cancel_callback),
					    &app->dialog);
		gnome_dialog_set_default(GNOME_DIALOG(app->dialog),0);
		
		label=gtk_label_new(_("Where to extract?"));
		gtk_box_pack_start(GTK_BOX(GNOME_DIALOG(app->dialog)->vbox),
				   label,  TRUE,TRUE,TRUE);
		
		app->dialog_entry=gnome_file_entry_new(
			"uncompress_dirs",
			"Select directory");
                   /* gtk_entry_new(); */
		gnome_file_entry_set_directory(
			GNOME_FILE_ENTRY(app->dialog_entry),0);
		gnome_file_entry_set_default_path(
			GNOME_FILE_ENTRY(app->dialog_entry),
			getenv("HOME"));
		gtk_box_pack_start(GTK_BOX(GNOME_DIALOG(app->dialog)->vbox),
				   app->dialog_entry, TRUE,TRUE,TRUE);
		
		lcaseNamesButton=
			gtk_check_button_new_with_label(
				_("Lowercase filenames"));
		app->dialog_lcase_names_button=lcaseNamesButton;
		
		gtk_toggle_button_set_state(
			GTK_TOGGLE_BUTTON(lcaseNamesButton),0);
		gtk_box_pack_start(
			GTK_BOX(GNOME_DIALOG(app->dialog)->vbox),
			lcaseNamesButton,TRUE,TRUE,TRUE);

		
		
		rButton1=gtk_radio_button_new_with_label(NULL,
							 _("Selected file"));
		gtk_box_pack_start(
			GTK_BOX(GNOME_DIALOG(app->dialog)->vbox),rButton1,
			TRUE,TRUE,TRUE);
		
		gtk_signal_connect(
			GTK_OBJECT(rButton1),"toggled",
			GTK_SIGNAL_FUNC(selected_file_toggled_callback),app);
		
		buttonGroup=gtk_radio_button_group(
			GTK_RADIO_BUTTON(rButton1));
		rButton2=gtk_radio_button_new_with_label(buttonGroup,
							 _("All files"));
		
		gtk_box_pack_start(GTK_BOX(GNOME_DIALOG(app->dialog)->vbox),
				   rButton2,TRUE,TRUE,TRUE);
		
		gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(rButton2),TRUE);
		gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(rButton1),FALSE);
		
		app->oneFile=0;

		gtk_widget_show_all(app->dialog);
	}
}
