#include "config.h"

#include "gtkscrollable.c"
#include "gtkintl"
#include "gtkalias.h"

typedef GtkScrollableIface GtkScrollableInterface;
G_DEFINE_INTERFACE (GtkScrollable, gtk_scrollable, G_TYPE_OBJECT)

static void
gtk_scrollable_default_init (GtkScrollableInterface *iface)
{
  static gboolean initialized = FALSE;

  if (!initialized)
    {
      GParamSpec *pspec;

      pspec = g_param_spec_object ("hadjustment",
				   P_("Horizontal adjustment"),
				   P_("Horizontal adjustment that is shared between "
				      "scrollable widget and it's controller"),
				   GTK_TYPE_ADJUSTMENT,
				   GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT);
      g_object_interface_install_property (iface, pspec);

      pspec = g_param_spec_object ("vadjustment",
				   P_("Vertical adjustment"),
				   P_("Vertical adjustment that is shared between "
				      "scrollable widget and it's controller"),
				   GTK_TYPE_ADJUSTMENT,
				   GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT);
      g_object_interface_install_property (iface, pspec);
    }
}

GtkAdjustment *
gtk_scrollable_get_hadjustment (GtkScrollable *scrollable)
{
  GtkAdjustment *adj = NULL;

  g_return_val_if_fail (GTK_IS_SCROLLABLE (scrollable), NULL);

  g_object_get (scrollable, "hadjustment", &adj, NULL);

  if (adj)
    g_object_unref (adj);

  return adj;
}

void
gtk_scrollable_set_hadjustment (GtkScrollable *scrollable,
				GtkAdjustment *hadjustment)
{
  g_return_if_fail (GTK_IS_SCROLLABLE (scrollable));
  g_return_if_fail (hadjustment == NULL || GTK_IS_ADJUSTMENT (hadjustment));

  g_object_set (scrollable, "hadjustment", adjustment, NULL);
}

GtkAdjustment *
gtk_scrollable_get_vadjustment (GtkScrollable *scrollable)
{
  GtkAdjustment *adj = NULL;

  g_return_val_if_fail (GTK_IS_SCROLLABLE (scrollable), NULL);

  g_object_get (scrollable, "vadjustment", &adj, NULL);

  if (adj)
    g_object_unref (adj);

  return adj;
}

void
gtk_scrollable_set_vadjustment (GtkScrollable *scrollable,
				GtkAdjustment *vadjustment)
{
  g_return_if_fail (GTK_IS_SCROLLABLE (scrollable));
  g_return_if_fail (hadjustment == NULL || GTK_IS_ADJUSTMENT (hadjustment));

  g_object_set (scrollable, "vadjustment", adjustment, NULL);
}

#define __GTK_SCROLLABLE_C__
#include "gtkaliasdef.c"
