/* 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 GTKMM_API Video : public Widget
{
  _CLASS_GTKOBJECT(Video, GtkVideo, GTK_VIDEO, Gtk::Widget, GtkWidget, , , GTKMM_API)
  _DO_NOT_DERIVE_GTYPE dnl// GtkVideo is a final type
  _ABI_AS_WITH_DERIVED_GTYPE dnl// Remove when we can break ABI
  _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)

  _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_METHOD(GraphicsOffloadEnabled get_graphics_offload() const, gtk_video_get_graphics_offload)
  _WRAP_METHOD(void set_graphics_offload(GraphicsOffloadEnabled enabled), gtk_video_set_graphics_offload)

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

  // There are no signals or vfuncs.
};

} //namespace Gtk
