/*
 * DO NOT EDIT THIS FILE - it is generated by Glade.
 */

#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>

#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>

#include "callbacks.h"
#include "interface.h"
#include "support.h"

#define GLADE_HOOKUP_OBJECT(component,widget,name) \
  g_object_set_data_full (G_OBJECT (component), name, \
    gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref)

#define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \
  g_object_set_data (G_OBJECT (component), name, widget)

GtkWidget*
create_mainwindow (void)
{
  GtkWidget *mainwindow;
  GdkPixbuf *mainwindow_icon_pixbuf;
  GtkWidget *vbox1;
  GtkWidget *hbox6;
  GtkWidget *image5;
  GtkWidget *label1;
  GtkWidget *hbox1;
  GtkWidget *rbstd;
  GSList *rbstd_group = NULL;
  GtkWidget *rbdeep;
  GtkWidget *rbopt;
  GtkWidget *hseparator1;
  GtkWidget *hbuttonbox1;
  GtkWidget *startbtn;
  GtkWidget *alignment1;
  GtkWidget *hbox2;
  GtkWidget *image1;
  GtkWidget *label2;
  GtkWidget *exitbtn;
  GtkWidget *alignment2;
  GtkWidget *hbox3;
  GtkWidget *image2;
  GtkWidget *label3;
  GtkTooltips *tooltips;

  tooltips = gtk_tooltips_new ();

  mainwindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_position (GTK_WINDOW (mainwindow), GTK_WIN_POS_CENTER);
  gtk_window_set_resizable (GTK_WINDOW (mainwindow), FALSE);
  mainwindow_icon_pixbuf = create_pixbuf ("icon-32x32.xpm");
  if (mainwindow_icon_pixbuf)
    {
      gtk_window_set_icon (GTK_WINDOW (mainwindow), mainwindow_icon_pixbuf);
      gdk_pixbuf_unref (mainwindow_icon_pixbuf);
    }
  gtk_window_set_role (GTK_WINDOW (mainwindow), "ramdefrag-main");

  vbox1 = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (vbox1);
  gtk_container_add (GTK_CONTAINER (mainwindow), vbox1);
  gtk_container_set_border_width (GTK_CONTAINER (vbox1), 5);

  hbox6 = gtk_hbox_new (FALSE, 0);
  gtk_widget_show (hbox6);
  gtk_box_pack_start (GTK_BOX (vbox1), hbox6, FALSE, FALSE, 0);

  image5 = create_pixmap (mainwindow, "icon-32x32.xpm");
  gtk_widget_show (image5);
  gtk_box_pack_start (GTK_BOX (hbox6), image5, TRUE, TRUE, 0);
  gtk_misc_set_padding (GTK_MISC (image5), 5, 5);

  label1 = gtk_label_new (_("Welcome!\n<b>Multi Platform RAM Defragmentation</b> gives you all the possibilities of similar MS Windows[tm] products:\nChoose your personal defragmentation method and watch your PC getting faster instantly!"));
  gtk_widget_show (label1);
  gtk_box_pack_start (GTK_BOX (hbox6), label1, FALSE, FALSE, 0);
  gtk_label_set_use_markup (GTK_LABEL (label1), TRUE);
  gtk_label_set_justify (GTK_LABEL (label1), GTK_JUSTIFY_FILL);
  gtk_label_set_line_wrap (GTK_LABEL (label1), TRUE);

  hbox1 = gtk_hbox_new (FALSE, 5);
  gtk_widget_show (hbox1);
  gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (hbox1), 5);

  rbstd = gtk_radio_button_new_with_mnemonic (NULL, _("S_tandard Defrag"));
  gtk_widget_show (rbstd);
  gtk_box_pack_start (GTK_BOX (hbox1), rbstd, FALSE, FALSE, 0);
  gtk_tooltips_set_tip (tooltips, rbstd, _("this is the default defragmentation method"), NULL);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (rbstd), rbstd_group);
  rbstd_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (rbstd));
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (rbstd), TRUE);

  rbdeep = gtk_radio_button_new_with_mnemonic (NULL, _("\"_Deep\" Defrag"));
  gtk_widget_show (rbdeep);
  gtk_box_pack_start (GTK_BOX (hbox1), rbdeep, FALSE, FALSE, 0);
  gtk_tooltips_set_tip (tooltips, rbdeep, _("the \"Deep\" optimizer code does a better job than the default method, but it takes more time"), NULL);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (rbdeep), rbstd_group);
  rbstd_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (rbdeep));

  rbopt = gtk_radio_button_new_with_mnemonic (NULL, _("_Optimized Defrag"));
  gtk_widget_show (rbopt);
  gtk_box_pack_start (GTK_BOX (hbox1), rbopt, FALSE, FALSE, 0);
  gtk_tooltips_set_tip (tooltips, rbopt, _("select this special optimizer code for best performance"), NULL);
  gtk_radio_button_set_group (GTK_RADIO_BUTTON (rbopt), rbstd_group);
  rbstd_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (rbopt));

  hseparator1 = gtk_hseparator_new ();
  gtk_widget_show (hseparator1);
  gtk_box_pack_start (GTK_BOX (vbox1), hseparator1, TRUE, TRUE, 0);

  hbuttonbox1 = gtk_hbutton_box_new ();
  gtk_widget_show (hbuttonbox1);
  gtk_box_pack_start (GTK_BOX (vbox1), hbuttonbox1, TRUE, TRUE, 0);
  gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox1), GTK_BUTTONBOX_END);
  gtk_box_set_spacing (GTK_BOX (hbuttonbox1), 15);

  startbtn = gtk_button_new ();
  gtk_widget_show (startbtn);
  gtk_container_add (GTK_CONTAINER (hbuttonbox1), startbtn);
  gtk_container_set_border_width (GTK_CONTAINER (startbtn), 2);
  GTK_WIDGET_SET_FLAGS (startbtn, GTK_CAN_DEFAULT);
  gtk_tooltips_set_tip (tooltips, startbtn, _("start optimizing process..."), NULL);

  alignment1 = gtk_alignment_new (0.5, 0.5, 0, 0);
  gtk_widget_show (alignment1);
  gtk_container_add (GTK_CONTAINER (startbtn), alignment1);

  hbox2 = gtk_hbox_new (FALSE, 3);
  gtk_widget_show (hbox2);
  gtk_container_add (GTK_CONTAINER (alignment1), hbox2);

  image1 = gtk_image_new_from_stock ("gtk-execute", GTK_ICON_SIZE_BUTTON);
  gtk_widget_show (image1);
  gtk_box_pack_start (GTK_BOX (hbox2), image1, FALSE, FALSE, 0);

  label2 = gtk_label_new_with_mnemonic (_("_Start Optimizer!"));
  gtk_widget_show (label2);
  gtk_box_pack_start (GTK_BOX (hbox2), label2, FALSE, FALSE, 0);

  exitbtn = gtk_button_new ();
  gtk_widget_show (exitbtn);
  gtk_container_add (GTK_CONTAINER (hbuttonbox1), exitbtn);
  gtk_container_set_border_width (GTK_CONTAINER (exitbtn), 2);
  GTK_WIDGET_SET_FLAGS (exitbtn, GTK_CAN_DEFAULT);
  gtk_tooltips_set_tip (tooltips, exitbtn, _("quit ramdefrag"), NULL);

  alignment2 = gtk_alignment_new (0.5, 0.5, 0, 0);
  gtk_widget_show (alignment2);
  gtk_container_add (GTK_CONTAINER (exitbtn), alignment2);

  hbox3 = gtk_hbox_new (FALSE, 3);
  gtk_widget_show (hbox3);
  gtk_container_add (GTK_CONTAINER (alignment2), hbox3);

  image2 = gtk_image_new_from_stock ("gtk-quit", GTK_ICON_SIZE_BUTTON);
  gtk_widget_show (image2);
  gtk_box_pack_start (GTK_BOX (hbox3), image2, FALSE, FALSE, 0);

  label3 = gtk_label_new_with_mnemonic (_("_Quit this program"));
  gtk_widget_show (label3);
  gtk_box_pack_start (GTK_BOX (hbox3), label3, FALSE, FALSE, 0);

  g_signal_connect ((gpointer) mainwindow, "delete_event",
                    G_CALLBACK (gtk_main_quit),
                    NULL);
  g_signal_connect_swapped ((gpointer) startbtn, "clicked",
                            G_CALLBACK (on_startbtn_clicked),
                            GTK_OBJECT (mainwindow));
  g_signal_connect ((gpointer) exitbtn, "clicked",
                    G_CALLBACK (gtk_main_quit),
                    NULL);

  /* Store pointers to all widgets, for use by lookup_widget(). */
  GLADE_HOOKUP_OBJECT_NO_REF (mainwindow, mainwindow, "mainwindow");
  GLADE_HOOKUP_OBJECT (mainwindow, vbox1, "vbox1");
  GLADE_HOOKUP_OBJECT (mainwindow, hbox6, "hbox6");
  GLADE_HOOKUP_OBJECT (mainwindow, image5, "image5");
  GLADE_HOOKUP_OBJECT (mainwindow, label1, "label1");
  GLADE_HOOKUP_OBJECT (mainwindow, hbox1, "hbox1");
  GLADE_HOOKUP_OBJECT (mainwindow, rbstd, "rbstd");
  GLADE_HOOKUP_OBJECT (mainwindow, rbdeep, "rbdeep");
  GLADE_HOOKUP_OBJECT (mainwindow, rbopt, "rbopt");
  GLADE_HOOKUP_OBJECT (mainwindow, hseparator1, "hseparator1");
  GLADE_HOOKUP_OBJECT (mainwindow, hbuttonbox1, "hbuttonbox1");
  GLADE_HOOKUP_OBJECT (mainwindow, startbtn, "startbtn");
  GLADE_HOOKUP_OBJECT (mainwindow, alignment1, "alignment1");
  GLADE_HOOKUP_OBJECT (mainwindow, hbox2, "hbox2");
  GLADE_HOOKUP_OBJECT (mainwindow, image1, "image1");
  GLADE_HOOKUP_OBJECT (mainwindow, label2, "label2");
  GLADE_HOOKUP_OBJECT (mainwindow, exitbtn, "exitbtn");
  GLADE_HOOKUP_OBJECT (mainwindow, alignment2, "alignment2");
  GLADE_HOOKUP_OBJECT (mainwindow, hbox3, "hbox3");
  GLADE_HOOKUP_OBJECT (mainwindow, image2, "image2");
  GLADE_HOOKUP_OBJECT (mainwindow, label3, "label3");
  GLADE_HOOKUP_OBJECT_NO_REF (mainwindow, tooltips, "tooltips");

  gtk_widget_grab_default (startbtn);
  return mainwindow;
}

GtkWidget*
create_defragwindow (void)
{
  GtkWidget *defragwindow;
  GtkWidget *vbox2;
  GtkWidget *label4;
  GtkWidget *lblstat;
  GtkWidget *progressbar;
  GtkWidget *hbuttonbox2;
  GtkWidget *cancelbtn;
  GtkWidget *alignment3;
  GtkWidget *hbox4;
  GtkWidget *image3;
  GtkWidget *label6;
  GtkTooltips *tooltips;

  tooltips = gtk_tooltips_new ();

  defragwindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (defragwindow), _("Defragmentation in progress..."));
  gtk_window_set_position (GTK_WINDOW (defragwindow), GTK_WIN_POS_CENTER);
  gtk_window_set_modal (GTK_WINDOW (defragwindow), TRUE);
  gtk_window_set_resizable (GTK_WINDOW (defragwindow), FALSE);
  gtk_window_set_type_hint (GTK_WINDOW (defragwindow), GDK_WINDOW_TYPE_HINT_DIALOG);

  vbox2 = gtk_vbox_new (FALSE, 2);
  gtk_widget_show (vbox2);
  gtk_container_add (GTK_CONTAINER (defragwindow), vbox2);
  gtk_container_set_border_width (GTK_CONTAINER (vbox2), 10);

  label4 = gtk_label_new (_("Status:"));
  gtk_widget_show (label4);
  gtk_box_pack_start (GTK_BOX (vbox2), label4, FALSE, FALSE, 0);
  gtk_label_set_justify (GTK_LABEL (label4), GTK_JUSTIFY_CENTER);

  lblstat = gtk_label_new (_("[ready]"));
  gtk_widget_show (lblstat);
  gtk_box_pack_start (GTK_BOX (vbox2), lblstat, FALSE, FALSE, 0);
  gtk_label_set_justify (GTK_LABEL (lblstat), GTK_JUSTIFY_CENTER);

  progressbar = gtk_progress_bar_new ();
  gtk_widget_show (progressbar);
  gtk_box_pack_start (GTK_BOX (vbox2), progressbar, FALSE, FALSE, 0);
  gtk_widget_set_size_request (progressbar, 250, -1);
  gtk_progress_bar_set_text (GTK_PROGRESS_BAR (progressbar), "0 %");

  hbuttonbox2 = gtk_hbutton_box_new ();
  gtk_widget_show (hbuttonbox2);
  gtk_box_pack_start (GTK_BOX (vbox2), hbuttonbox2, TRUE, TRUE, 0);
  gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox2), GTK_BUTTONBOX_END);
  gtk_box_set_spacing (GTK_BOX (hbuttonbox2), 15);

  cancelbtn = gtk_button_new ();
  gtk_widget_show (cancelbtn);
  gtk_container_add (GTK_CONTAINER (hbuttonbox2), cancelbtn);
  gtk_container_set_border_width (GTK_CONTAINER (cancelbtn), 2);
  GTK_WIDGET_SET_FLAGS (cancelbtn, GTK_CAN_DEFAULT);
  gtk_tooltips_set_tip (tooltips, cancelbtn, _("cancel the defragmentation process"), NULL);

  alignment3 = gtk_alignment_new (0.5, 0.5, 0, 0);
  gtk_widget_show (alignment3);
  gtk_container_add (GTK_CONTAINER (cancelbtn), alignment3);

  hbox4 = gtk_hbox_new (FALSE, 2);
  gtk_widget_show (hbox4);
  gtk_container_add (GTK_CONTAINER (alignment3), hbox4);

  image3 = gtk_image_new_from_stock ("gtk-cancel", GTK_ICON_SIZE_BUTTON);
  gtk_widget_show (image3);
  gtk_box_pack_start (GTK_BOX (hbox4), image3, FALSE, FALSE, 0);

  label6 = gtk_label_new_with_mnemonic (_("_Cancel"));
  gtk_widget_show (label6);
  gtk_box_pack_start (GTK_BOX (hbox4), label6, FALSE, FALSE, 0);

  g_signal_connect ((gpointer) cancelbtn, "clicked",
                    G_CALLBACK (on_cancelbtn_clicked),
                    NULL);

  /* Store pointers to all widgets, for use by lookup_widget(). */
  GLADE_HOOKUP_OBJECT_NO_REF (defragwindow, defragwindow, "defragwindow");
  GLADE_HOOKUP_OBJECT (defragwindow, vbox2, "vbox2");
  GLADE_HOOKUP_OBJECT (defragwindow, label4, "label4");
  GLADE_HOOKUP_OBJECT (defragwindow, lblstat, "lblstat");
  GLADE_HOOKUP_OBJECT (defragwindow, progressbar, "progressbar");
  GLADE_HOOKUP_OBJECT (defragwindow, hbuttonbox2, "hbuttonbox2");
  GLADE_HOOKUP_OBJECT (defragwindow, cancelbtn, "cancelbtn");
  GLADE_HOOKUP_OBJECT (defragwindow, alignment3, "alignment3");
  GLADE_HOOKUP_OBJECT (defragwindow, hbox4, "hbox4");
  GLADE_HOOKUP_OBJECT (defragwindow, image3, "image3");
  GLADE_HOOKUP_OBJECT (defragwindow, label6, "label6");
  GLADE_HOOKUP_OBJECT_NO_REF (defragwindow, tooltips, "tooltips");

  gtk_widget_grab_default (cancelbtn);
  return defragwindow;
}

GtkWidget*
create_summarywindow (void)
{
  GtkWidget *summarywindow;
  GtkWidget *vbox3;
  GtkWidget *label7;
  GtkWidget *scrolledwindow1;
  GtkWidget *textbox;
  GtkWidget *hbuttonbox3;
  GtkWidget *okbutton;
  GtkWidget *alignment4;
  GtkWidget *hbox5;
  GtkWidget *image4;
  GtkWidget *label8;
  GtkTooltips *tooltips;

  tooltips = gtk_tooltips_new ();

  summarywindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (summarywindow), _("Defragmentation complete"));
  gtk_window_set_position (GTK_WINDOW (summarywindow), GTK_WIN_POS_CENTER);
  gtk_window_set_modal (GTK_WINDOW (summarywindow), TRUE);
  gtk_window_set_resizable (GTK_WINDOW (summarywindow), FALSE);
  gtk_window_set_type_hint (GTK_WINDOW (summarywindow), GDK_WINDOW_TYPE_HINT_DIALOG);

  vbox3 = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (vbox3);
  gtk_container_add (GTK_CONTAINER (summarywindow), vbox3);
  gtk_container_set_border_width (GTK_CONTAINER (vbox3), 10);

  label7 = gtk_label_new (_("<b>Defragmentation complete!</b>\nDetailed report:"));
  gtk_widget_show (label7);
  gtk_box_pack_start (GTK_BOX (vbox3), label7, FALSE, FALSE, 0);
  gtk_label_set_use_markup (GTK_LABEL (label7), TRUE);
  gtk_label_set_justify (GTK_LABEL (label7), GTK_JUSTIFY_CENTER);

  scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL);
  gtk_widget_show (scrolledwindow1);
  gtk_box_pack_start (GTK_BOX (vbox3), scrolledwindow1, TRUE, TRUE, 0);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_SHADOW_ETCHED_IN);

  textbox = gtk_text_view_new ();
  gtk_widget_show (textbox);
  gtk_container_add (GTK_CONTAINER (scrolledwindow1), textbox);
  gtk_widget_set_size_request (textbox, 300, 150);
  gtk_tooltips_set_tip (tooltips, textbox, _("detailed report"), NULL);
  gtk_text_view_set_editable (GTK_TEXT_VIEW (textbox), FALSE);
  gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (textbox), FALSE);
  gtk_text_view_set_left_margin (GTK_TEXT_VIEW (textbox), 3);
  gtk_text_view_set_right_margin (GTK_TEXT_VIEW (textbox), 3);

  hbuttonbox3 = gtk_hbutton_box_new ();
  gtk_widget_show (hbuttonbox3);
  gtk_box_pack_start (GTK_BOX (vbox3), hbuttonbox3, FALSE, TRUE, 0);
  gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox3), GTK_BUTTONBOX_END);
  gtk_box_set_spacing (GTK_BOX (hbuttonbox3), 15);

  okbutton = gtk_button_new ();
  gtk_widget_show (okbutton);
  gtk_container_add (GTK_CONTAINER (hbuttonbox3), okbutton);
  gtk_container_set_border_width (GTK_CONTAINER (okbutton), 3);
  GTK_WIDGET_SET_FLAGS (okbutton, GTK_CAN_DEFAULT);
  gtk_tooltips_set_tip (tooltips, okbutton, _("quit ramdefrag"), NULL);

  alignment4 = gtk_alignment_new (0.5, 0.5, 0, 0);
  gtk_widget_show (alignment4);
  gtk_container_add (GTK_CONTAINER (okbutton), alignment4);

  hbox5 = gtk_hbox_new (FALSE, 2);
  gtk_widget_show (hbox5);
  gtk_container_add (GTK_CONTAINER (alignment4), hbox5);

  image4 = gtk_image_new_from_stock ("gtk-quit", GTK_ICON_SIZE_BUTTON);
  gtk_widget_show (image4);
  gtk_box_pack_start (GTK_BOX (hbox5), image4, FALSE, FALSE, 0);

  label8 = gtk_label_new_with_mnemonic (_("_OK, quit this program"));
  gtk_widget_show (label8);
  gtk_box_pack_start (GTK_BOX (hbox5), label8, FALSE, FALSE, 0);

  g_signal_connect ((gpointer) okbutton, "clicked",
                    G_CALLBACK (on_okbutton_clicked),
                    NULL);

  /* Store pointers to all widgets, for use by lookup_widget(). */
  GLADE_HOOKUP_OBJECT_NO_REF (summarywindow, summarywindow, "summarywindow");
  GLADE_HOOKUP_OBJECT (summarywindow, vbox3, "vbox3");
  GLADE_HOOKUP_OBJECT (summarywindow, label7, "label7");
  GLADE_HOOKUP_OBJECT (summarywindow, scrolledwindow1, "scrolledwindow1");
  GLADE_HOOKUP_OBJECT (summarywindow, textbox, "textbox");
  GLADE_HOOKUP_OBJECT (summarywindow, hbuttonbox3, "hbuttonbox3");
  GLADE_HOOKUP_OBJECT (summarywindow, okbutton, "okbutton");
  GLADE_HOOKUP_OBJECT (summarywindow, alignment4, "alignment4");
  GLADE_HOOKUP_OBJECT (summarywindow, hbox5, "hbox5");
  GLADE_HOOKUP_OBJECT (summarywindow, image4, "image4");
  GLADE_HOOKUP_OBJECT (summarywindow, label8, "label8");
  GLADE_HOOKUP_OBJECT_NO_REF (summarywindow, tooltips, "tooltips");

  gtk_widget_grab_focus (okbutton);
  gtk_widget_grab_default (okbutton);
  return summarywindow;
}

