/* Copyright (C) 2018 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, see <http://www.gnu.org/licenses/>.
 */

#include <gtkmm/widget.h>
#include <gtkmm/mediastream.h>
#include <giomm/file.h>

_DEFS(gtkmm,gtk)
_PINCLUDE(gtkmm/private/widget_p.h)

namespace Gtk
{

/**  A widget for displaying video.
 *
 * %Gtk::Video is a widget to show a Gtk::MediaStream.
 * It is commonly combined with Gtk::MediaControls to give the
 * user a way to control the playback.
 *
 * @ingroup Widgets
 *
 * @newin{3,94}
 */
class Video : public Widget
{
  _CLASS_GTKOBJECT(Video, GtkVideo, GTK_VIDEO, Gtk::Widget, GtkWidget)
  _STRUCT_NOT_HIDDEN

public:
  _CTOR_DEFAULT

  /** Creates a %Gtk::Video to play back the given @a media_stream.
   *
   * @param media_stream A Gtk::MediaStream or an empty Glib::RefPtr.
   */
  _WRAP_CTOR(Video(const Glib::RefPtr<MediaStream>& media_stream), gtk_video_new_for_media_stream)

  /** Creates a %Gtk::Video to play back the given @a file.
   *
   * @param file A Gio::File or an empty Glib::RefPtr.
   */
  _WRAP_CTOR(Video(const Glib::RefPtr<Gio::File>& file), gtk_video_new_for_file)

  // gtk_video_new_for_filename() does more than just call g_object_new().
  // GtkVideo has no "filename" property.
  /** Creates a %Gtk::Video to play back the given @a filename.
   *
   * This constructor calls Video(const Glib::RefPtr<Gio::File>& file).
   * See that constructor for details.
   *
   * @param filename Filename to play back or an empty string.
   */
  explicit Video(const std::string& filename);
  _IGNORE(gtk_video_new_for_filename)

  // We don't wrap gtk_video_new_for_resource() to avoid a clash with
  // the for_filename constructor. But we do wrap gtk_video_set_resource().
  _IGNORE(gtk_video_new_for_resource)

  _WRAP_METHOD(Glib::RefPtr<MediaStream> get_media_stream(), gtk_video_get_media_stream, refreturn)
  _WRAP_METHOD(Glib::RefPtr<const MediaStream> get_media_stream() const, gtk_video_get_media_stream, refreturn, constversion)
  _WRAP_METHOD(void set_media_stream(const Glib::RefPtr<MediaStream>& stream), gtk_video_set_media_stream, refreturn, constversion)

  _WRAP_METHOD(Glib::RefPtr<Gio::File> get_file(), gtk_video_get_file, refreturn)
  _WRAP_METHOD(Glib::RefPtr<const Gio::File> get_file() const, gtk_video_get_file, refreturn, constversion)
  _WRAP_METHOD(void set_file(const Glib::RefPtr<const Gio::File>& file), gtk_video_set_file)

  _WRAP_METHOD(void set_filename(const std::string& filename), gtk_video_set_filename)
  _WRAP_METHOD(void set_resource(const std::string& resource_path), gtk_video_set_resource)

  _WRAP_METHOD(bool get_autoplay() const, gtk_video_get_autoplay)
  _WRAP_METHOD(void set_autoplay(bool autoplay = true), gtk_video_set_autoplay)
  _WRAP_METHOD(bool get_loop() const, gtk_video_get_loop)
  _WRAP_METHOD(void set_loop(bool loop = true), gtk_video_set_loop)

  _WRAP_PROPERTY("media-stream", Glib::RefPtr<MediaStream>)
  _WRAP_PROPERTY("file", Glib::RefPtr<Gio::File>)
  _WRAP_PROPERTY("autoplay", bool)
  _WRAP_PROPERTY("loop", bool)

  // There are no signals or vfuncs.
};

} //namespace Gtk
