From 21d0ba654b820c3b07c73b61287e3a73549d4e1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Fri, 3 May 2024 09:29:02 +0200 Subject: [PATCH] WIP: clapper-gtk: Add new ClapperGtkEngageLayer widget --- .../clapper-gtk/clapper-gtk-engage-layer.c | 102 ++++++++++++++++++ .../clapper-gtk/clapper-gtk-engage-layer.h | 41 +++++++ .../clapper-gtk/clapper-gtk.gresources.xml | 1 + src/lib/clapper-gtk/clapper-gtk.h | 1 + src/lib/clapper-gtk/meson.build | 2 + .../ui/clapper-gtk-engage-layer.ui | 17 +++ 6 files changed, 164 insertions(+) create mode 100644 src/lib/clapper-gtk/clapper-gtk-engage-layer.c create mode 100644 src/lib/clapper-gtk/clapper-gtk-engage-layer.h create mode 100644 src/lib/clapper-gtk/ui/clapper-gtk-engage-layer.ui diff --git a/src/lib/clapper-gtk/clapper-gtk-engage-layer.c b/src/lib/clapper-gtk/clapper-gtk-engage-layer.c new file mode 100644 index 00000000..c64dbf77 --- /dev/null +++ b/src/lib/clapper-gtk/clapper-gtk-engage-layer.c @@ -0,0 +1,102 @@ +/* Clapper GTK Integration Library + * Copyright (C) 2024 Rafał Dzięgiel + * + * 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., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +/** + * ClapperGtkEngageLayer: + * + * A layer with big `play` button, engaging user to start the playback. + * + * #ClapperGtkEngageLayer widget is meant to be overlaid on top of + * [class@ClapperGtk.Video] as a normal (non-fading) overlay. It takes + * care of fading itself once clicked and/or when playback is started. + * + * Since: 0.8 + */ + +#include "config.h" + +#include + +#include "clapper-gtk-engage-layer.h" + +#define GST_CAT_DEFAULT clapper_gtk_engage_layer_debug +GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT); + +struct _ClapperGtkEngageLayer +{ + ClapperGtkLeadContainer parent; +}; + +#define parent_class clapper_gtk_engage_layer_parent_class +G_DEFINE_TYPE (ClapperGtkEngageLayer, clapper_gtk_engage_layer, CLAPPER_GTK_TYPE_LEAD_CONTAINER) + +static void +adapt_cb (ClapperGtkContainer *container, gboolean adapt, + ClapperGtkEngageLayer *self) +{ + GST_DEBUG_OBJECT (self, "Adapted: %s", (adapt) ? "yes" : "no"); +} + +/** + * clapper_gtk_engage_layer_new: + * + * Creates a new #ClapperGtkEngageLayer instance. + * + * Returns: a new playback engage layer #GtkWidget. + * + * Since: 0.8 + */ +GtkWidget * +clapper_gtk_engage_layer_new (void) +{ + return g_object_new (CLAPPER_GTK_TYPE_ENGAGE_LAYER, NULL); +} + +static void +clapper_gtk_engage_layer_init (ClapperGtkEngageLayer *self) +{ + gtk_widget_init_template (GTK_WIDGET (self)); +} + +static void +clapper_gtk_engage_layer_dispose (GObject *object) +{ + gtk_widget_dispose_template (GTK_WIDGET (object), CLAPPER_GTK_TYPE_ENGAGE_LAYER); + + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +static void +clapper_gtk_engage_layer_class_init (ClapperGtkEngageLayerClass *klass) +{ + GObjectClass *gobject_class = (GObjectClass *) klass; + GtkWidgetClass *widget_class = (GtkWidgetClass *) klass; + + GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "clappergtkengagelayer", 0, + "Clapper GTK Engage Layer"); + + gobject_class->dispose = clapper_gtk_engage_layer_dispose; + + gtk_widget_class_set_template_from_resource (widget_class, + CLAPPER_GTK_RESOURCE_PREFIX "/ui/clapper-gtk-engage-layer.ui"); + + gtk_widget_class_bind_template_callback (widget_class, adapt_cb); + + gtk_widget_class_set_css_name (widget_class, "clapper-gtk-engage-layer"); +} diff --git a/src/lib/clapper-gtk/clapper-gtk-engage-layer.h b/src/lib/clapper-gtk/clapper-gtk-engage-layer.h new file mode 100644 index 00000000..8cdaa137 --- /dev/null +++ b/src/lib/clapper-gtk/clapper-gtk-engage-layer.h @@ -0,0 +1,41 @@ +/* Clapper GTK Integration Library + * Copyright (C) 2024 Rafał Dzięgiel + * + * 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., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#pragma once + +#if !defined(__CLAPPER_GTK_INSIDE__) && !defined(CLAPPER_GTK_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include +#include + +#include + +G_BEGIN_DECLS + +#define CLAPPER_GTK_TYPE_ENGAGE_LAYER (clapper_gtk_engage_layer_get_type()) +#define CLAPPER_GTK_ENGAGE_LAYER_CAST(obj) ((ClapperGtkEngageLayer *)(obj)) + +G_DECLARE_FINAL_TYPE (ClapperGtkEngageLayer, clapper_gtk_engage_layer, CLAPPER_GTK, ENGAGE_LAYER, ClapperGtkLeadContainer) + +GtkWidget * clapper_gtk_engage_layer_new (void); + +G_END_DECLS diff --git a/src/lib/clapper-gtk/clapper-gtk.gresources.xml b/src/lib/clapper-gtk/clapper-gtk.gresources.xml index c25bb2f6..fe83597d 100644 --- a/src/lib/clapper-gtk/clapper-gtk.gresources.xml +++ b/src/lib/clapper-gtk/clapper-gtk.gresources.xml @@ -2,6 +2,7 @@ ui/clapper-gtk-billboard.ui + ui/clapper-gtk-engage-layer.ui ui/clapper-gtk-extra-menu-button.ui ui/clapper-gtk-seek-bar.ui ui/clapper-gtk-simple-controls.ui diff --git a/src/lib/clapper-gtk/clapper-gtk.h b/src/lib/clapper-gtk/clapper-gtk.h index f34608ed..1dd18c32 100644 --- a/src/lib/clapper-gtk/clapper-gtk.h +++ b/src/lib/clapper-gtk/clapper-gtk.h @@ -26,6 +26,7 @@ #include #include +#include #include #include #include diff --git a/src/lib/clapper-gtk/meson.build b/src/lib/clapper-gtk/meson.build index 0a9db374..4ed580c0 100644 --- a/src/lib/clapper-gtk/meson.build +++ b/src/lib/clapper-gtk/meson.build @@ -80,6 +80,7 @@ clappergtk_headers = [ 'clapper-gtk-enums.h', 'clapper-gtk-billboard.h', 'clapper-gtk-container.h', + 'clapper-gtk-engage-layer.h', 'clapper-gtk-extra-menu-button.h', 'clapper-gtk-lead-container.h', 'clapper-gtk-next-item-button.h', @@ -99,6 +100,7 @@ clappergtk_sources = [ 'clapper-gtk-buffering-animation.c', 'clapper-gtk-buffering-paintable.c', 'clapper-gtk-container.c', + 'clapper-gtk-engage-layer.c', 'clapper-gtk-extra-menu-button.c', 'clapper-gtk-lead-container.c', 'clapper-gtk-limited-layout.c', diff --git a/src/lib/clapper-gtk/ui/clapper-gtk-engage-layer.ui b/src/lib/clapper-gtk/ui/clapper-gtk-engage-layer.ui new file mode 100644 index 00000000..cbd2b258 --- /dev/null +++ b/src/lib/clapper-gtk/ui/clapper-gtk-engage-layer.ui @@ -0,0 +1,17 @@ + + + +