/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */

/*
 *  Copyright (C) 2004 Takuro Ashie
 *
 *  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 this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 *  #Id: $
 */

#include "kz-bookmark-edit-win.h"

#include <glib/gi18n.h>
#include "kz-icons.h"
#include "kz-bookmark-edit.h"

static void dispose    (GObject   *object);
static void response   (GtkDialog *dialog,
                        gint       arg);

G_DEFINE_TYPE(KzBookmarkEditWin, kz_bookmark_edit_win, GTK_TYPE_DIALOG)

static void
kz_bookmark_edit_win_class_init (KzBookmarkEditWinClass *klass)
{
	GObjectClass *object_class;
	GtkDialogClass *dialog_class;

	object_class = (GObjectClass *) klass;
	dialog_class = (GtkDialogClass *) klass;

	object_class->dispose  = dispose;

	dialog_class->response = response;
}


static void
kz_bookmark_edit_win_init (KzBookmarkEditWin *win)
{
	GtkWidget *edit;

	gtk_window_set_default_size(GTK_WINDOW(win), 600, 400);
	gtk_window_set_icon(GTK_WINDOW(win), kz_icon);

	gtk_dialog_add_buttons(GTK_DIALOG(win),
			       GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
			       NULL);

	/* paned */
	edit = kz_bookmark_edit_new();
	gtk_box_pack_start(GTK_BOX(GTK_DIALOG(win)->vbox), 
			   edit, TRUE, TRUE, 0);
	gtk_widget_show(edit);

	/* initialize member */
	win->bookmark_edit = edit;
}


static void
dispose (GObject *object)
{
	KzBookmarkEditWin *win = KZ_BOOKMARK_EDIT_WIN(object);

	win->bookmark_edit = NULL;

	if (G_OBJECT_CLASS(kz_bookmark_edit_win_parent_class)->dispose)
		G_OBJECT_CLASS(kz_bookmark_edit_win_parent_class)->dispose(object);
}


static void
response (GtkDialog *dialog, gint arg)
{
	switch (arg)
	{
	case GTK_RESPONSE_CLOSE:
		gtk_widget_destroy(GTK_WIDGET(dialog));
		break;
	default:
		break;
	}
}


GtkWidget *
kz_bookmark_edit_win_new (KzBookmark *bookmark)
{
	GObject *obj;
	KzBookmarkEditWin *win;

	obj = g_object_new(KZ_TYPE_BOOKMARK_EDIT_WIN,
			   "title", _("Kazehakase Bookmark Editor"),
			   NULL);
	win = KZ_BOOKMARK_EDIT_WIN(obj);

	if (KZ_IS_BOOKMARK(bookmark))
		kz_bookmark_edit_set(KZ_BOOKMARK_EDIT(win->bookmark_edit),
				     bookmark);

	return GTK_WIDGET(win);
}
