/*
 * 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;
  GtkWidget *vbox1;
  GtkWidget *toolbar2;
  GtkIconSize tmp_toolbar_icon_size;
  GtkWidget *btnOpen;
  GtkWidget *toolitem4;
  GtkWidget *vseparator1;
  GtkWidget *toolitem3;
  GtkWidget *entFolder;
  GtkWidget *btnCancel;
  GtkWidget *btnReload;
  GtkWidget *btnOnlyOneFileSystem;
  GtkWidget *toolbutton2;
  GtkWidget *btnAbout;
  GtkWidget *scrolledwindow1;
  GtkWidget *TVtreeView;
  GtkWidget *statusbar1;
  GtkAccelGroup *accel_group;
  GtkTooltips *tooltips;

  tooltips = gtk_tooltips_new ();

  accel_group = gtk_accel_group_new ();

  mainWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (mainWindow), "TreeSize by marcos@unitron.com.br");
  gtk_window_set_position (GTK_WINDOW (mainWindow), GTK_WIN_POS_CENTER);
  gtk_window_set_modal (GTK_WINDOW (mainWindow), TRUE);
  gtk_window_set_default_size (GTK_WINDOW (mainWindow), 400, 400);
  gtk_window_set_destroy_with_parent (GTK_WINDOW (mainWindow), TRUE);

  vbox1 = gtk_vbox_new (FALSE, 0);
  gtk_widget_show (vbox1);
  gtk_container_add (GTK_CONTAINER (mainWindow), vbox1);

  toolbar2 = gtk_toolbar_new ();
  gtk_widget_show (toolbar2);
  gtk_box_pack_start (GTK_BOX (vbox1), toolbar2, FALSE, TRUE, 0);
  gtk_toolbar_set_style (GTK_TOOLBAR (toolbar2), GTK_TOOLBAR_ICONS);
  tmp_toolbar_icon_size = gtk_toolbar_get_icon_size (GTK_TOOLBAR (toolbar2));

  btnOpen = (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-open");
  gtk_widget_show (btnOpen);
  gtk_container_add (GTK_CONTAINER (toolbar2), btnOpen);
  gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (btnOpen), tooltips, "Open", NULL);
  gtk_widget_add_accelerator (btnOpen, "clicked", accel_group,
                              GDK_O, (GdkModifierType) GDK_CONTROL_MASK,
                              GTK_ACCEL_VISIBLE);

  toolitem4 = (GtkWidget*) gtk_tool_item_new ();
  gtk_widget_show (toolitem4);
  gtk_container_add (GTK_CONTAINER (toolbar2), toolitem4);

  vseparator1 = gtk_vseparator_new ();
  gtk_widget_show (vseparator1);
  gtk_container_add (GTK_CONTAINER (toolitem4), vseparator1);

  toolitem3 = (GtkWidget*) gtk_tool_item_new ();
  gtk_widget_show (toolitem3);
  gtk_container_add (GTK_CONTAINER (toolbar2), toolitem3);

  entFolder = gtk_entry_new ();
  gtk_widget_show (entFolder);
  gtk_container_add (GTK_CONTAINER (toolitem3), entFolder);
  gtk_widget_set_size_request (entFolder, 210, -1);
  gtk_widget_add_accelerator (entFolder, "grab_focus", accel_group,
                              GDK_L, (GdkModifierType) GDK_CONTROL_MASK,
                              GTK_ACCEL_VISIBLE);
  gtk_entry_set_activates_default (GTK_ENTRY (entFolder), TRUE);

  btnCancel = (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-stop");
  gtk_widget_show (btnCancel);
  gtk_container_add (GTK_CONTAINER (toolbar2), btnCancel);
  gtk_widget_set_sensitive (btnCancel, FALSE);
  gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (btnCancel), tooltips, "Cancel", NULL);
  gtk_widget_add_accelerator (btnCancel, "clicked", accel_group,
                              GDK_Escape, (GdkModifierType) 0,
                              GTK_ACCEL_VISIBLE);

  btnReload = (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-refresh");
  gtk_widget_show (btnReload);
  gtk_container_add (GTK_CONTAINER (toolbar2), btnReload);
  gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (btnReload), tooltips, "Reload", NULL);

  btnOnlyOneFileSystem = (GtkWidget*) gtk_toggle_tool_button_new_from_stock ("gtk-harddisk");
  gtk_widget_show (btnOnlyOneFileSystem);
  gtk_container_add (GTK_CONTAINER (toolbar2), btnOnlyOneFileSystem);
  gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (btnOnlyOneFileSystem), tooltips, _("skip directories on different file systems"), NULL);

  toolbutton2 = (GtkWidget*) gtk_separator_tool_item_new ();
  gtk_widget_show (toolbutton2);
  gtk_container_add (GTK_CONTAINER (toolbar2), toolbutton2);

  btnAbout = (GtkWidget*) gtk_tool_button_new_from_stock ("gtk-dialog-info");
  gtk_widget_show (btnAbout);
  gtk_container_add (GTK_CONTAINER (toolbar2), btnAbout);
  gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (btnAbout), tooltips, "About", NULL);

  scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL);
  gtk_widget_show (scrolledwindow1);
  gtk_box_pack_start (GTK_BOX (vbox1), scrolledwindow1, TRUE, TRUE, 0);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_SHADOW_IN);

  TVtreeView = gtk_tree_view_new ();
  gtk_widget_show (TVtreeView);
  gtk_container_add (GTK_CONTAINER (scrolledwindow1), TVtreeView);
  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (TVtreeView), FALSE);
  gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (TVtreeView), TRUE);

  statusbar1 = gtk_statusbar_new ();
  gtk_widget_show (statusbar1);
  gtk_box_pack_start (GTK_BOX (vbox1), statusbar1, FALSE, FALSE, 0);

  g_signal_connect ((gpointer) mainWindow, "size_allocate",
                    G_CALLBACK (on_mainWindow_size_allocate),
                    NULL);
  g_signal_connect ((gpointer) mainWindow, "delete_event",
                    G_CALLBACK (gtk_main_quit),
                    NULL);
  g_signal_connect ((gpointer) btnOpen, "clicked",
                    G_CALLBACK (on_btnOpen_clicked),
                    NULL);
  g_signal_connect ((gpointer) entFolder, "key_press_event",
                    G_CALLBACK (on_entFolder_key_press_event),
                    NULL);
  g_signal_connect ((gpointer) btnCancel, "clicked",
                    G_CALLBACK (on_btnCancel_clicked),
                    NULL);
  g_signal_connect ((gpointer) btnReload, "clicked",
                    G_CALLBACK (on_btnReload_clicked),
                    NULL);
  g_signal_connect ((gpointer) btnAbout, "clicked",
                    G_CALLBACK (on_btnAbout_clicked),
                    NULL);
  g_signal_connect ((gpointer) TVtreeView, "button_press_event",
                    G_CALLBACK (on_TVtreeView_button_press_event),
                    NULL);
  g_signal_connect ((gpointer) TVtreeView, "key_press_event",
                    G_CALLBACK (on_TVtreeView_key_press_event),
                    NULL);
  g_signal_connect ((gpointer) TVtreeView, "row_activated",
                    G_CALLBACK (on_TVtreeView_row_activated),
                    NULL);
  g_signal_connect ((gpointer) TVtreeView, "cursor_changed",
                    G_CALLBACK (on_TVtreeView_cursor_changed),
                    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, toolbar2, "toolbar2");
  GLADE_HOOKUP_OBJECT (mainWindow, btnOpen, "btnOpen");
  GLADE_HOOKUP_OBJECT (mainWindow, toolitem4, "toolitem4");
  GLADE_HOOKUP_OBJECT (mainWindow, vseparator1, "vseparator1");
  GLADE_HOOKUP_OBJECT (mainWindow, toolitem3, "toolitem3");
  GLADE_HOOKUP_OBJECT (mainWindow, entFolder, "entFolder");
  GLADE_HOOKUP_OBJECT (mainWindow, btnCancel, "btnCancel");
  GLADE_HOOKUP_OBJECT (mainWindow, btnReload, "btnReload");
  GLADE_HOOKUP_OBJECT (mainWindow, btnOnlyOneFileSystem, "btnOnlyOneFileSystem");
  GLADE_HOOKUP_OBJECT (mainWindow, toolbutton2, "toolbutton2");
  GLADE_HOOKUP_OBJECT (mainWindow, btnAbout, "btnAbout");
  GLADE_HOOKUP_OBJECT (mainWindow, scrolledwindow1, "scrolledwindow1");
  GLADE_HOOKUP_OBJECT (mainWindow, TVtreeView, "TVtreeView");
  GLADE_HOOKUP_OBJECT (mainWindow, statusbar1, "statusbar1");
  GLADE_HOOKUP_OBJECT_NO_REF (mainWindow, tooltips, "tooltips");

  gtk_widget_grab_focus (TVtreeView);
  gtk_window_add_accel_group (GTK_WINDOW (mainWindow), accel_group);

  return mainWindow;
}

GtkWidget*
create_ChooseFolder (void)
{
  GtkWidget *ChooseFolder;
  GtkWidget *dialog_vbox2;
  GtkWidget *dialog_action_area2;
  GtkWidget *btnCFcancel;
  GtkWidget *btnCFopen;

  ChooseFolder = gtk_file_chooser_dialog_new ("Please choose a folder", NULL, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, NULL);
  gtk_container_set_border_width (GTK_CONTAINER (ChooseFolder), 5);
  gtk_window_set_position (GTK_WINDOW (ChooseFolder), GTK_WIN_POS_CENTER);
  gtk_window_set_modal (GTK_WINDOW (ChooseFolder), TRUE);
  gtk_window_set_type_hint (GTK_WINDOW (ChooseFolder), GDK_WINDOW_TYPE_HINT_DIALOG);

  dialog_vbox2 = GTK_DIALOG (ChooseFolder)->vbox;
  gtk_widget_show (dialog_vbox2);

  dialog_action_area2 = GTK_DIALOG (ChooseFolder)->action_area;
  gtk_widget_show (dialog_action_area2);
  gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area2), GTK_BUTTONBOX_END);

  btnCFcancel = gtk_button_new_from_stock ("gtk-cancel");
  gtk_widget_show (btnCFcancel);
  gtk_dialog_add_action_widget (GTK_DIALOG (ChooseFolder), btnCFcancel, GTK_RESPONSE_CANCEL);
  GTK_WIDGET_SET_FLAGS (btnCFcancel, GTK_CAN_DEFAULT);

  btnCFopen = gtk_button_new_from_stock ("gtk-open");
  gtk_widget_show (btnCFopen);
  gtk_dialog_add_action_widget (GTK_DIALOG (ChooseFolder), btnCFopen, GTK_RESPONSE_OK);
  GTK_WIDGET_SET_FLAGS (btnCFopen, GTK_CAN_DEFAULT);

  g_signal_connect_swapped ((gpointer) btnCFcancel, "clicked",
                            G_CALLBACK (gtk_widget_destroy),
                            GTK_OBJECT (ChooseFolder));
  g_signal_connect ((gpointer) btnCFopen, "clicked",
                    G_CALLBACK (on_btnCFopen_clicked),
                    NULL);

  /* Store pointers to all widgets, for use by lookup_widget(). */
  GLADE_HOOKUP_OBJECT_NO_REF (ChooseFolder, ChooseFolder, "ChooseFolder");
  GLADE_HOOKUP_OBJECT_NO_REF (ChooseFolder, dialog_vbox2, "dialog_vbox2");
  GLADE_HOOKUP_OBJECT_NO_REF (ChooseFolder, dialog_action_area2, "dialog_action_area2");
  GLADE_HOOKUP_OBJECT (ChooseFolder, btnCFcancel, "btnCFcancel");
  GLADE_HOOKUP_OBJECT (ChooseFolder, btnCFopen, "btnCFopen");

  gtk_widget_grab_default (btnCFopen);
  return ChooseFolder;
}

GtkWidget*
create_AboutDialog (void)
{
  GtkWidget *AboutDialog;
  const gchar *authors[] = {
    "Marcos Diez marcos@unitron.com.br",
    NULL
  };
  const gchar *artists[] = {
    "Icon from http://en.wikipedia.org/wiki/Image:Square1.jpg",
    "Idea from Anna Barankow",
    NULL
  };
  /* TRANSLATORS: Replace this string with your names, one name per line. */
  gchar *translators = _("translator-credits");
  GtkWidget *dialog_vbox3;

  AboutDialog = gtk_about_dialog_new ();
  gtk_container_set_border_width (GTK_CONTAINER (AboutDialog), 5);
  gtk_about_dialog_set_version (GTK_ABOUT_DIALOG (AboutDialog), VERSION);
  gtk_about_dialog_set_name (GTK_ABOUT_DIALOG (AboutDialog), _("Treesize"));
  gtk_about_dialog_set_copyright (GTK_ABOUT_DIALOG (AboutDialog), _("Marcos Diez marcos@unitron.com.br (Oct 2006)"));
  gtk_about_dialog_set_comments (GTK_ABOUT_DIALOG (AboutDialog), _("TreeSize for Unix uses physical file sizes, which means sparse files occupy which are not necessarily what programs like 'ls' display. \n\nJust like 'du', multiple instances of hard links are counted only once. On the other hand floating point division is used to round the file sizes, so results here should be a little bit bigger, but precise."));
  gtk_about_dialog_set_license (GTK_ABOUT_DIALOG (AboutDialog), _("This program is free software; you can redistribute it and/or modify it\nunder the terms of the GNU General Public License as published by the \nFree Software Foundation; either version 3 of the License, or (at your option)\nany later version.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT\nANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\nFITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License \nfor more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program; if not, see <http://www.gnu.org/licenses/>.\n"));
  gtk_about_dialog_set_website (GTK_ABOUT_DIALOG (AboutDialog), "http://treesize.sourceforge.net");
  gtk_about_dialog_set_website_label (GTK_ABOUT_DIALOG (AboutDialog), _("http://treesize.sourceforge.net"));
  gtk_about_dialog_set_authors (GTK_ABOUT_DIALOG (AboutDialog), authors);
  gtk_about_dialog_set_artists (GTK_ABOUT_DIALOG (AboutDialog), artists);
  gtk_about_dialog_set_translator_credits (GTK_ABOUT_DIALOG (AboutDialog), translators);

  dialog_vbox3 = gtk_vbox_new (FALSE, 0);
  gtk_container_add (GTK_CONTAINER (AboutDialog), dialog_vbox3);

  g_signal_connect ((gpointer) AboutDialog, "response",
                    G_CALLBACK (gtk_widget_destroy),
                    NULL);

  /* Store pointers to all widgets, for use by lookup_widget(). */
  GLADE_HOOKUP_OBJECT_NO_REF (AboutDialog, AboutDialog, "AboutDialog");
  GLADE_HOOKUP_OBJECT (AboutDialog, dialog_vbox3, "dialog_vbox3");

  return AboutDialog;
}

GtkWidget*
create_TreeSizeMenu (void)
{
  GtkWidget *TreeSizeMenu;
  GtkWidget *menuOpen;
  GtkWidget *image3;
  GtkWidget *menuXtermHere;
  GtkWidget *menuCopy_folder_path;
  GtkWidget *image4;

  TreeSizeMenu = gtk_menu_new ();

  menuOpen = gtk_image_menu_item_new_with_mnemonic (_("O_pen"));
  gtk_widget_show (menuOpen);
  gtk_container_add (GTK_CONTAINER (TreeSizeMenu), menuOpen);

  image3 = gtk_image_new_from_stock ("gtk-open", GTK_ICON_SIZE_MENU);
  gtk_widget_show (image3);
  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuOpen), image3);

  menuXtermHere = gtk_menu_item_new_with_mnemonic (_("_Terminal Here"));
  gtk_widget_show (menuXtermHere);
  gtk_container_add (GTK_CONTAINER (TreeSizeMenu), menuXtermHere);

  menuCopy_folder_path = gtk_image_menu_item_new_with_mnemonic (_("_Copy Folder Path"));
  gtk_widget_show (menuCopy_folder_path);
  gtk_container_add (GTK_CONTAINER (TreeSizeMenu), menuCopy_folder_path);

  image4 = gtk_image_new_from_stock ("gtk-copy", GTK_ICON_SIZE_MENU);
  gtk_widget_show (image4);
  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuCopy_folder_path), image4);

  g_signal_connect ((gpointer) menuOpen, "activate",
                    G_CALLBACK (on_menuOpen_activate),
                    NULL);
  g_signal_connect ((gpointer) menuXtermHere, "activate",
                    G_CALLBACK (on_menuXtermHere_activate),
                    NULL);
  g_signal_connect ((gpointer) menuCopy_folder_path, "activate",
                    G_CALLBACK (on_menuCopy_folder_path_activate),
                    NULL);

  /* Store pointers to all widgets, for use by lookup_widget(). */
  GLADE_HOOKUP_OBJECT_NO_REF (TreeSizeMenu, TreeSizeMenu, "TreeSizeMenu");
  GLADE_HOOKUP_OBJECT (TreeSizeMenu, menuOpen, "menuOpen");
  GLADE_HOOKUP_OBJECT (TreeSizeMenu, image3, "image3");
  GLADE_HOOKUP_OBJECT (TreeSizeMenu, menuXtermHere, "menuXtermHere");
  GLADE_HOOKUP_OBJECT (TreeSizeMenu, menuCopy_folder_path, "menuCopy_folder_path");
  GLADE_HOOKUP_OBJECT (TreeSizeMenu, image4, "image4");

  return TreeSizeMenu;
}

