/*
 Copyright (C) 2011-2012 Christian Dywan <christian@twotoasts.de>

 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public
 License as published by the Free Software Foundation; either
 version 2.1 of the License, or (at your option) any later version.

 See the file COPYING for the full license text.
*/

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

#ifndef H_GTK3_COMPAT_20110110
#define H_GTK3_COMPAT_20110110

G_BEGIN_DECLS

#if GTK_CHECK_VERSION (3, 2, 0) && defined (GTK_DISABLE_DEPRECATED)
    #define GTK_TYPE_VBOX GTK_TYPE_BOX
    #define GtkVBox GtkBox
    #define GtkVBoxClass GtkBoxClass
    #define gtk_vbox_new(hmg,spc) g_object_new (GTK_TYPE_BOX, \
        "homogeneous", hmg, "spacing", spc, \
        "orientation", GTK_ORIENTATION_VERTICAL, NULL)
    #define GTK_TYPE_HBOX GTK_TYPE_BOX
    #define GtkHBox GtkBox
    #define GtkHBoxClass GtkBoxClass
    #define gtk_hbox_new(hmg,spc) g_object_new (GTK_TYPE_BOX, \
        "homogeneous", hmg, "spacing", spc, \
        "orientation", GTK_ORIENTATION_HORIZONTAL, NULL)
    #define gtk_hseparator_new() g_object_new (GTK_TYPE_SEPARATOR, NULL)
    #define gtk_hpaned_new() g_object_new (GTK_TYPE_PANED, NULL)
    #define gtk_vpaned_new() g_object_new (GTK_TYPE_PANED, \
        "orientation", GTK_ORIENTATION_VERTICAL, NULL)
    /* FIXME */
    #define gtk_widget_render_icon(wdgt, stk, sz, dtl) \
        gtk_widget_render_icon_pixbuf(wdgt, stk, sz)
    #define gtk_widget_size_request(wdgt, req) \
        gtk_widget_get_preferred_size(wdgt, req, NULL)
#endif

#if !GLIB_CHECK_VERSION (2, 32, 0)
    #define G_SOURCE_REMOVE   FALSE
    #define G_SOURCE_CONTINUE TRUE
#endif

#if !GLIB_CHECK_VERSION (2, 30, 0)
    #define g_format_size(sz) g_format_size_for_display ((goffset)sz)
#endif

#if !GTK_CHECK_VERSION (2, 18, 0)
    #define gtk_widget_is_toplevel(widget) GTK_WIDGET_TOPLEVEL (widget)
    #define gtk_widget_has_focus(widget) GTK_WIDGET_HAS_FOCUS (widget)
    #define gtk_widget_get_visible(widget) GTK_WIDGET_VISIBLE (widget)
    #define gtk_widget_get_sensitive(widget) GTK_WIDGET_IS_SENSITIVE (widget)
    #define gtk_widget_set_can_focus(widget,flag) \
        GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS)
    #define gtk_widget_get_allocation(wdgt, alloc) *alloc = wdgt->allocation
    #define gtk_widget_get_has_window(wdgt) !GTK_WIDGET_NO_WINDOW (wdgt)
    #define gtk_widget_get_allocation(wdgt, alloc) *alloc = wdgt->allocation
    #define gtk_widget_set_window(wdgt, wndw) wdgt->window = wndw
    #define gtk_widget_is_drawable GTK_WIDGET_DRAWABLE
    #define gtk_widget_get_drawable GTK_WIDGET_VISIBLE
    #define gtk_widget_set_has_window(wdgt, wnd) \
        if (wnd) GTK_WIDGET_UNSET_FLAGS (wdgt, GTK_NO_WINDOW); \
        else GTK_WIDGET_SET_FLAGS (wdgt, GTK_NO_WINDOW)
#endif

#if !GTK_CHECK_VERSION (2, 20, 0)
    #define gtk_widget_get_realized(widget) GTK_WIDGET_REALIZED (widget)
    #define gtk_widget_set_realized(wdgt, real) \
        if (real) GTK_WIDGET_SET_FLAGS (wdgt, GTK_REALIZED); \
        else GTK_WIDGET_UNSET_FLAGS (wdgt, GTK_REALIZED)
#endif

#if GTK_CHECK_VERSION (3, 0, 0)
    #define GTK_DIALOG_NO_SEPARATOR 0
#endif

#if !GTK_CHECK_VERSION (3, 2, 0)
    void gtk_entry_set_placeholder_text (GtkEntry* entry, const gchar* text);
    const gchar* gtk_entry_get_placeholder_text (GtkEntry* entry);
#endif

#if !GTK_CHECK_VERSION (2, 24 ,0)
    #define gtk_combo_box_text_append_text gtk_combo_box_append_text
    #define gtk_combo_box_text_new gtk_combo_box_new_text
    #define gtk_combo_box_text_new_with_entry gtk_combo_box_entry_new_text
    #define gtk_combo_box_text_get_active_text gtk_combo_box_get_active_text
    #define GTK_COMBO_BOX_TEXT GTK_COMBO_BOX
    #define GtkComboBoxText GtkComboBox
#endif

#ifndef GDK_KEY_Return
    #define GDK_KEY_0 GDK_0
    #define GDK_KEY_BackSpace GDK_BackSpace
    #define GDK_KEY_space GDK_space
    #define GDK_KEY_F5 GDK_F5
    #define GDK_KEY_KP_Equal GDK_KP_Equal
    #define GDK_KEY_KP_Enter GDK_KP_Enter
    #define GDK_KEY_KP_Left GDK_KP_Left
    #define GDK_KEY_KP_Right GDK_KP_Right
    #define GDK_KEY_KP_Delete GDK_KP_Delete
    #define GDK_KEY_KP_Down GDK_KP_Down
    #define GDK_KEY_KP_Up GDK_KP_Up
    #define GDK_KEY_KP_Divide GDK_KP_Divide
    #define GDK_KEY_Tab GDK_Tab
    #define GDK_KEY_ISO_Left_Tab GDK_ISO_Left_Tab
    #define GDK_KEY_equal GDK_equal
    #define GDK_KEY_ISO_Enter GDK_ISO_Enter
    #define GDK_KEY_Left GDK_Left
    #define GDK_KEY_Right GDK_Right
    #define GDK_KEY_Escape GDK_Escape
    #define GDK_KEY_Page_Up GDK_Page_Up
    #define GDK_KEY_Page_Down GDK_Page_Down
    #define GDK_KEY_Delete GDK_Delete
    #define GDK_KEY_Down GDK_Down
    #define GDK_KEY_Up GDK_Up
    #define GDK_KEY_B GDK_B
    #define GDK_KEY_H GDK_H
    #define GDK_KEY_J GDK_J
    #define GDK_KEY_Return GDK_Return
#endif

#ifdef GDK_WINDOWING_X11
    #include <gdk/gdkx.h>
    #ifndef GDK_IS_X11_DISPLAY
        #define GDK_IS_X11_DISPLAY(display) TRUE
    #endif
#endif

G_END_DECLS

#endif
