// -*- c++ -*-
/* $Id: toolbar.ccg,v 1.6 2004/03/03 18:48:04 murrayc Exp $ */

/* 
 *
 * Copyright 1998-2002 The gtkmm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

//Define this to make sure that we don't use any of the deprecated GtkToolbar API.
//Normally we just deprecate it in gtkmm too,
//but the GtkToolbar compatibility system is particularly unpleasant, so we just removed it in gtkmm 2.4. murrayc.
//In future, this GTK_DISABLE_DEPRECATED might be inappropriate because it might cover extra GTK+ API. Just remove it then.

#define GTK_DISABLE_DEPRECATED

#include <glib.h>
#include <gtkmm/button.h>
#include <gtkmm/togglebutton.h>
#include <gtkmm/radiobutton.h>
#include <gtkmm/tooltips.h>
//#include <gtkmm/image.h>
#include <gtkmm/label.h>
#include <gtk/gtklabel.h>
#include <gtk/gtktoolbar.h>

namespace Gtk
{

void Toolbar::insert(ToolButton& item, int pos, const sigc::slot<void>& clicked_slot)
{
  item.signal_clicked().connect(clicked_slot);
  gtk_toolbar_insert(gobj(), (GtkToolItem*)((item).gobj()), pos);
}

void Toolbar::insert(ToggleToolButton& item, int pos, const sigc::slot<void>& toggled_slot)
{
  item.signal_toggled().connect(toggled_slot);
  gtk_toolbar_insert(gobj(), (GtkToolItem*)((item).gobj()), pos);
}

void Toolbar::append(ToolItem& item)
{
  gtk_toolbar_insert(gobj(), (item).gobj(), -1 /* See GTK+ docs */);
}

void Toolbar::append(ToolButton& item, const sigc::slot<void>& clicked_slot)
{
  item.signal_clicked().connect(clicked_slot);
  gtk_toolbar_insert(gobj(), (GtkToolItem*)((item).gobj()), -1 /* See GTK+ docs */);
}

void Toolbar::append(ToggleToolButton& item, const sigc::slot<void>& toggled_slot)
{
  item.signal_toggled().connect(toggled_slot);
  gtk_toolbar_insert(gobj(), (GtkToolItem*)((item).gobj()), -1 /* See GTK+ docs */);
}

void Toolbar::prepend(ToolItem& item)
{
  gtk_toolbar_insert(gobj(), (item).gobj(), 0 /* See GTK+ docs */);
}

void Toolbar::prepend(ToolButton& item, const sigc::slot<void>& clicked_slot)
{
  item.signal_clicked().connect(clicked_slot);
  gtk_toolbar_insert(gobj(), (GtkToolItem*)((item).gobj()), 0 /* See GTK+ docs */);
}

void Toolbar::prepend(ToggleToolButton& item, const sigc::slot<void>& toggled_slot)
{
  item.signal_toggled().connect(toggled_slot);
  gtk_toolbar_insert(gobj(), (GtkToolItem*)((item).gobj()), 0 /* See GTK+ docs */);
}

void Toolbar::unset_drop_highlight_item()
{
  //See GTK+ docs.
  gtk_toolbar_set_drop_highlight_item(gobj(), 0, 0);
}

#ifndef GTKMM_DISABLE_DEPRECATED
Tooltips* Toolbar::get_tooltips_object() const
{
  //Note that the _tooltips field is deprecated and broken since GTK+ 2.12:
  return Glib::wrap((GtkTooltips*)gobj()->_tooltips);
}
#endif //GTKMM_DISABLE_DEPRECATED

} // namespace Gtk

