// -*- c++ -*-
/* $Id: statusicon.ccg,v 1.4 2006/06/21 20:34:39 murrayc Exp $ */

/* Copyright 2005 The gtkmm Development Team
 *
 * 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.
 *
 * 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <gtk/gtk.h>


namespace Gtk
{

Glib::RefPtr<StatusIcon> StatusIcon::create_from_file(const std::string& filename)
{
  Glib::RefPtr<StatusIcon> status_icon( new StatusIcon() );
  status_icon->set_from_file(filename);
  return status_icon;
}

bool StatusIcon::get_geometry(Glib::RefPtr<Gdk::Screen>& screen, Gdk::Rectangle& area, Orientation& orientation)
{
  GdkScreen* cscreen = 0;
  GdkRectangle carea;
  const bool result = gtk_status_icon_get_geometry(const_cast<GtkStatusIcon*>(gobj()), &cscreen, &carea, (GtkOrientation*)(&orientation));

  if(cscreen)
  {
    screen = Glib::wrap(cscreen);
    screen->reference();
  }

  *(area.gobj()) = carea;

  return result;
}

void StatusIcon::popup_menu_at_position(Menu& menu, guint button, guint32 activate_time)
{
  gtk_menu_popup(menu.gobj(), NULL, NULL,
    gtk_status_icon_position_menu, gobj() /* user_data, passed to gtk_status_icon_position_menu()/ */,
    button, activate_time);
}

} // namespace Gtk

