/*
 *  Crow, a GUI designer for GTK+
 *  Copyright (c) 2005-2008 Maxim Udushlivy
 *
 *  Permission is hereby granted, free of charge, to any person 
 *  obtaining a copy of this software and associated documentation 
 *  files (the "Software"), to deal in the Software without 
 *  restriction, including without limitation the rights to use, copy, 
 *  modify, merge, publish, distribute, sublicense, and/or sell copies 
 *  of the Software, and to permit persons to whom the Software is 
 *  furnished to do so, subject to the following conditions:
 *
 *  The above copyright notice and this permission notice shall be 
 *  included in all copies or substantial portions of the Software.
 *
 *  The software is provided "as is", without warranty of any kind, 
 *  express or implied, including but not limited to the warranties of 
 *  merchantability, fitness for a particular purpose and 
 *  noninfringement. In no event shall the authors or copyright 
 *  holders be liable for any claim, damages or other liability, 
 *  whether in an action of contract, tort or otherwise, arising from, 
 *  out of or in connection with the software or the use or other 
 *  dealings in the software.
 */

#ifndef CROW_CROW_H
#define CROW_CROW_H

#include <gtk/gtk.h>

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

#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
