/*
 *  Crow, a GUI designer for GTK+
 *  Copyright (c) 2005 Maxim Udushlivy
 *
 *  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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

#ifndef CROW_CROW_H
#define CROW_CROW_H

#include <gtk/gtk.h>

#define CROW_VERSION (2*1000000 + 11*1000 + 0)

#ifdef _WIN32
	#ifdef CROW_LIBRARY
		#define CROW_API __declspec(dllexport)
	#else
		#define CROW_API __declspec(dllimport)
	#endif
#else
	#define CROW_API __attribute__ ((visibility("default")))
#endif

typedef gint64 CrowActions;
#define CROW_ACTION_SAVE          (1LL <<  0)
#define CROW_ACTION_SHOULD_SAVE   (1LL <<  1)
#define CROW_ACTION_UNDO          (1LL <<  2)
#define CROW_ACTION_REDO          (1LL <<  3)
#define CROW_ACTION_CUT           (1LL <<  4)
#define CROW_ACTION_COPY          (1LL <<  5)
#define CROW_ACTION_PASTE         (1LL <<  6)
#define CROW_ACTION_PASTE_TO_ROOT (1LL <<  7)
#define CROW_ACTION_DELETE        (1LL <<  8)
#define CROW_ACTION_ABOUT         (1LL <<  9)
#define CROW_ACTION_PREVIEW       (1LL << 10)
#define CROW_ACTION_DEFAULT_SIZE  (1LL << 11)
#define CROW_ACTION_SHIFT_LEFT    (1LL << 12)
#define CROW_ACTION_SHIFT_RIGHT   (1LL << 13)
#define CROW_ACTION_TRANSLATABLES (1LL << 14)
#define CROW_ACTION_DEFAULT       (1LL << 15)
#define CROW_ACTION_ADD           (1LL << 16)
#define CROW_ACTION_REMOVE        (1LL << 17)
#define CROW_ACTION_MOVE_UP       (1LL << 18)
#define CROW_ACTION_MOVE_DOWN     (1LL << 19)

#define CROW_ACTIONS_SAVE (CROW_ACTION_SAVE|CROW_ACTION_SHOULD_SAVE)
#define CROW_ACTIONS_BASIC (                                               \
	CROW_ACTION_UNDO|CROW_ACTION_REDO|CROW_ACTION_CUT|CROW_ACTION_COPY|      \
	CROW_ACTION_PASTE|CROW_ACTION_PASTE_TO_ROOT|CROW_ACTION_DELETE|          \
	CROW_ACTION_ABOUT|CROW_ACTION_PREVIEW|CROW_ACTION_DEFAULT_SIZE|          \
	CROW_ACTION_SHIFT_LEFT|CROW_ACTION_SHIFT_RIGHT|CROW_ACTION_TRANSLATABLES \
)
#define CROW_ACTIONS_EXPLORER (                                            \
	CROW_ACTION_DEFAULT|CROW_ACTION_ADD|CROW_ACTION_REMOVE|                  \
	CROW_ACTION_MOVE_UP|CROW_ACTION_MOVE_DOWN                                \
)
#define CROW_ACTIONS_ALL (CROW_ACTIONS_SAVE|CROW_ACTIONS_BASIC|CROW_ACTIONS_EXPLORER)

G_BEGIN_DECLS

#define CROW_TYPE_DESIGNER (crow_designer_get_type())
#define CROW_DESIGNER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), CROW_TYPE_DESIGNER, CrowDesigner))
#define CROW_DESIGNER_CLASS(meta) (G_TYPE_CHECK_CLASS_CAST((meta), CROW_TYPE_DESIGNER, CrowDesignerClass))
#define CROW_IS_DESIGNER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), CROW_TYPE_DESIGNER))
#define CROW_IS_DESIGNER_CLASS(meta) (G_TYPE_CHECK_CLASS_TYPE((meta), CROW_TYPE_DESIGNER))
#define CROW_DESIGNER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), CROW_TYPE_DESIGNER, CrowDesignerClass))

#define CROW_ERROR (crow_error_quark())
#define CROW_TYPE_ERROR (crow_error_get_type()) 

typedef struct _CrowDesigner CrowDesigner;
typedef struct _CrowDesignerClass CrowDesignerClass;

typedef enum {
	CROW_ERROR_RUNTIME
} CrowError;

struct _CrowDesigner {
	GObject parent;
};

struct _CrowDesignerClass {
	GObjectClass parent;
	GObjectClass * parent_class;
};

#define crow_enter() crow_enter_check(NULL)

CROW_API gint crow_version(void);
CROW_API void crow_enter_check(const gchar * msg);
CROW_API void crow_leave(void);
CROW_API GQuark crow_error_quark(void);
CROW_API GType crow_error_get_type(void);

CROW_API GType crow_designer_get_type(void);
CROW_API CrowDesigner * crow_designer_new(void);
CROW_API void crow_designer_apply_settings(CrowDesigner * designer, GHashTable * settings);
CROW_API void crow_designer_store_settings(CrowDesigner * designer, GHashTable * settings);
CROW_API void crow_designer_clear(CrowDesigner * designer);
CROW_API gboolean crow_designer_load(CrowDesigner * designer, const gchar * data, GError ** error);
CROW_API gchar * crow_designer_save(CrowDesigner * designer);
CROW_API gchar * crow_designer_save_header(CrowDesigner * designer);
CROW_API void crow_designer_saved(CrowDesigner * designer);
CROW_API GtkWidget * crow_designer_get_widget(CrowDesigner * designer);
CROW_API CrowActions crow_designer_get_enabled_actions(CrowDesigner * designer);
CROW_API void crow_designer_run_action(CrowDesigner * designer, CrowActions action);

G_END_DECLS

#endif
