diff options
author | Bastien Nocera <hadess@hadess.net> | 2022-01-27 13:12:55 +0100 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2022-02-04 11:23:56 +0100 |
commit | 2f400816fd32cfa258ad7f3c724a9d1084d7f455 (patch) | |
tree | 3c12f53a75d2f391c8926a53bc095ff6af6331b8 /src | |
parent | 843d779e69bb1e51a05e2464622e645c13e0ab8f (diff) | |
download | totem-2f400816fd32cfa258ad7f3c724a9d1084d7f455.tar.gz |
all: Remove obsolete source files
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/bacon-video-controls-actor.c | 126 | ||||
-rw-r--r-- | src/backend/bacon-video-controls-actor.h | 59 | ||||
-rw-r--r-- | src/backend/bacon-video-spinner-actor.c | 125 | ||||
-rw-r--r-- | src/backend/bacon-video-spinner-actor.h | 59 | ||||
-rw-r--r-- | src/backend/clock.c | 183 | ||||
-rw-r--r-- | src/backend/clock.h | 55 | ||||
-rw-r--r-- | src/backend/totem-aspect-frame.c | 456 | ||||
-rw-r--r-- | src/backend/totem-aspect-frame.h | 90 |
8 files changed, 0 insertions, 1153 deletions
diff --git a/src/backend/bacon-video-controls-actor.c b/src/backend/bacon-video-controls-actor.c deleted file mode 100644 index 53855e32f..000000000 --- a/src/backend/bacon-video-controls-actor.c +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Overlaid controls - * - * Copyright (C) 2013 Bastien Nocera <hadess@hadess.net> - * - * This program 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, or (at your option) any later version. - * - * This program 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 program; if not, see <http://www.gnu.org/licenses/>. - * - */ - -#include "config.h" - -#include "bacon-video-controls-actor.h" -#include "bacon-time-label.h" - -struct BaconVideoControlsActorPrivate -{ - GtkBuilder *builder; - GtkRange *seek; - GObject *bvw; -}; - -G_DEFINE_TYPE_WITH_PRIVATE (BaconVideoControlsActor, bacon_video_controls_actor, GTK_CLUTTER_TYPE_ACTOR); - -static void -bacon_video_controls_actor_finalize (GObject *object) -{ - BaconVideoControlsActor *controls; - - controls = BACON_VIDEO_CONTROLS_ACTOR (object); - - g_object_unref (controls->priv->builder); - - G_OBJECT_CLASS (bacon_video_controls_actor_parent_class)->finalize (object); -} - -static void -bacon_video_controls_actor_constructed (GObject *object) -{ - GtkWidget *contents; - GdkRGBA transparent = { 0, 0, 0, 0 }; - BaconVideoControlsActor *controls; - - controls = BACON_VIDEO_CONTROLS_ACTOR (object); - - contents = GTK_WIDGET (gtk_builder_get_object (controls->priv->builder, "toolbar")); - g_object_set (object, "contents", contents, "opacity", OVERLAY_OPACITY, "x-expand", TRUE, NULL); - - /* Theming */ - gtk_style_context_add_class (gtk_widget_get_style_context (contents), "osd"); - gtk_style_context_add_class (gtk_widget_get_style_context (contents), "bottom"); - gtk_widget_override_background_color (gtk_clutter_actor_get_widget (GTK_CLUTTER_ACTOR (object)), 0, &transparent); -} - -static void -bacon_video_controls_actor_class_init (BaconVideoControlsActorClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - - gobject_class->finalize = bacon_video_controls_actor_finalize; - gobject_class->constructed = bacon_video_controls_actor_constructed; -} - -static void -setup_object (BaconVideoControlsActor *controls, - const char *name) -{ - GObject *obj; - - obj = gtk_builder_get_object (controls->priv->builder, name); - - /* Setup an easy way to lookup the widgets by name without - * exposing the API directly to totem */ - g_object_set_data (G_OBJECT (controls), name, obj); -} - -static void -disable_popover_transitions (BaconVideoControlsActor *controls) -{ - GtkPopover *popover; - GObject *obj; - - obj = gtk_builder_get_object (controls->priv->builder, "volume_button"); - popover = GTK_POPOVER (gtk_scale_button_get_popup (GTK_SCALE_BUTTON (obj))); - gtk_popover_set_transitions_enabled (popover, FALSE); -} - -static void -bacon_video_controls_actor_init (BaconVideoControlsActor *controls) -{ - const char *objects[] = { "toolbar", NULL }; - - controls->priv = bacon_video_controls_actor_get_instance_private (controls); - - g_type_class_ref (BACON_TYPE_TIME_LABEL); - - controls->priv->builder = gtk_builder_new (); - if (gtk_builder_add_objects_from_file (controls->priv->builder, DATADIR "/controls.ui", (gchar **) objects, NULL) == 0) - g_assert_not_reached (); - - setup_object (controls, "seek_scale"); - setup_object (controls, "controls_box"); - setup_object (controls, "go_button"); - setup_object (controls, "volume_button"); - setup_object (controls, "time_label"); - setup_object (controls, "time_rem_label"); - - disable_popover_transitions (controls); -} - -ClutterActor * -bacon_video_controls_actor_new (void) -{ - return g_object_new (BACON_TYPE_VIDEO_CONTROLS_ACTOR, NULL); -} diff --git a/src/backend/bacon-video-controls-actor.h b/src/backend/bacon-video-controls-actor.h deleted file mode 100644 index be1288c59..000000000 --- a/src/backend/bacon-video-controls-actor.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Overlaid controls - * - * Copyright (C) 2013 Bastien Nocera <hadess@hadess.net> - * - * This program 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, or (at your option) any later version. - * - * This program 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 program; if not, see <http://www.gnu.org/licenses/>. - * - */ - -#ifndef BACON_VIDEO_CONTROLS_ACTOR_H -#define BACON_VIDEO_CONTROLS_ACTOR_H - -#include <glib-object.h> -#include <clutter-gtk/clutter-gtk.h> - -G_BEGIN_DECLS - -#define OVERLAY_OPACITY 220 - -#define BACON_TYPE_VIDEO_CONTROLS_ACTOR (bacon_video_controls_actor_get_type ()) -#define BACON_VIDEO_CONTROLS_ACTOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BACON_TYPE_VIDEO_CONTROLS_ACTOR, BaconVideoControlsActor)) -#define BACON_VIDEO_CONTROLS_ACTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BACON_TYPE_VIDEO_CONTROLS_ACTOR, BaconVideoControlsActorClass)) -#define BACON_IS_VIDEO_CONTROLS_ACTOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BACON_TYPE_VIDEO_CONTROLS_ACTOR)) -#define BACON_IS_VIDEO_CONTROLS_ACTOR_CLASS(klass) (G_TYPE_INSTANCE_GET_CLASS ((klass), BACON_TYPE_VIDEO_CONTROLS_ACTOR)) -#define BACON_VIDEO_CONTROLS_ACTOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BACON_TYPE_VIDEO_CONTROLS_ACTOR, BaconVideoControlsActorClass)) - -typedef struct BaconVideoControlsActor BaconVideoControlsActor; -typedef struct BaconVideoControlsActorClass BaconVideoControlsActorClass; -typedef struct BaconVideoControlsActorPrivate BaconVideoControlsActorPrivate; - -struct BaconVideoControlsActor { - GtkClutterActor parent; - - BaconVideoControlsActorPrivate *priv; -}; - -struct BaconVideoControlsActorClass { - GtkClutterActorClass parent_class; -}; - -GType bacon_video_controls_actor_get_type (void); - -ClutterActor * bacon_video_controls_actor_new (void); - -G_END_DECLS - -#endif diff --git a/src/backend/bacon-video-spinner-actor.c b/src/backend/bacon-video-spinner-actor.c deleted file mode 100644 index ae38317a2..000000000 --- a/src/backend/bacon-video-spinner-actor.c +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Overlaid spinner - * - * Copyright (C) 2013 Bastien Nocera <hadess@hadess.net> - * - * This program 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, or (at your option) any later version. - * - * This program 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 program; if not, see <http://www.gnu.org/licenses/>. - * - */ - -#include "config.h" - -#include "bacon-video-spinner-actor.h" -#include "clock.h" - - -struct BaconVideoSpinnerActorPrivate -{ - ClutterActor *clock; -}; - -G_DEFINE_TYPE_WITH_PRIVATE (BaconVideoSpinnerActor, bacon_video_spinner_actor, CLUTTER_TYPE_ACTOR); - -enum { - PROP_0, - PROP_PERCENT -}; - -static void -bacon_video_spinner_actor_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - BaconVideoSpinnerActor *spinner = BACON_VIDEO_SPINNER_ACTOR (object); - - switch (property_id) { - case PROP_PERCENT: - g_object_set (G_OBJECT (spinner->priv->clock), "angle", g_value_get_float (value) * 360.0 / 100.0, NULL); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -static void -bacon_video_spinner_actor_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - BaconVideoSpinnerActor *spinner = BACON_VIDEO_SPINNER_ACTOR (object); - gfloat angle; - - switch (property_id) { - case PROP_PERCENT: - g_object_get (G_OBJECT (spinner->priv->clock), "angle", &angle, NULL); - g_value_set_float (value, angle / 360.0 * 100.0); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -static void -bacon_video_spinner_actor_class_init (BaconVideoSpinnerActorClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - - gobject_class->set_property = bacon_video_spinner_actor_set_property; - gobject_class->get_property = bacon_video_spinner_actor_get_property; - - g_object_class_install_property (gobject_class, PROP_PERCENT, - g_param_spec_float ("percent", "Percent", - "Percentage fill", - 0.0, 100.0, 0.0, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); -} - -static void -bacon_video_spinner_actor_init (BaconVideoSpinnerActor *spinner) -{ - ClutterActor *actor, *layout; - ClutterConstraint *constraint; - ClutterColor *color; - - spinner->priv = bacon_video_spinner_actor_get_instance_private (spinner); - actor = CLUTTER_ACTOR (spinner); - - /* We'll set that colour on the layout, as the child doesn't - * take the whole space */ - color = clutter_color_copy (clutter_color_get_static (CLUTTER_COLOR_BLACK)); - color->alpha = 128; - - spinner->priv->clock = clock_new (); - layout = g_object_new (CLUTTER_TYPE_ACTOR, - "layout-manager", clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_CENTER, CLUTTER_BIN_ALIGNMENT_CENTER), - "background-color", color, - NULL); - clutter_color_free (color); - clutter_actor_add_child (layout, spinner->priv->clock); - clutter_actor_add_child (actor, layout); - - constraint = clutter_bind_constraint_new (actor, CLUTTER_BIND_SIZE, 0.0); - clutter_actor_add_constraint_with_name (layout, "size", constraint); -} - -ClutterActor * -bacon_video_spinner_actor_new (void) -{ - return g_object_new (BACON_TYPE_VIDEO_SPINNER_ACTOR, NULL); -} diff --git a/src/backend/bacon-video-spinner-actor.h b/src/backend/bacon-video-spinner-actor.h deleted file mode 100644 index 9689857bd..000000000 --- a/src/backend/bacon-video-spinner-actor.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Overlaid spinner - * - * Copyright (C) 2013 Bastien Nocera <hadess@hadess.net> - * - * This program 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, or (at your option) any later version. - * - * This program 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 program; if not, see <http://www.gnu.org/licenses/>. - * - */ - -#ifndef BACON_VIDEO_SPINNER_ACTOR_H -#define BACON_VIDEO_SPINNER_ACTOR_H - -#include <glib-object.h> -#include <clutter-gtk/clutter-gtk.h> - -G_BEGIN_DECLS - -#define OVERLAY_OPACITY 220 - -#define BACON_TYPE_VIDEO_SPINNER_ACTOR (bacon_video_spinner_actor_get_type ()) -#define BACON_VIDEO_SPINNER_ACTOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BACON_TYPE_VIDEO_SPINNER_ACTOR, BaconVideoSpinnerActor)) -#define BACON_VIDEO_SPINNER_ACTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BACON_TYPE_VIDEO_SPINNER_ACTOR, BaconVideoSpinnerActorClass)) -#define BACON_IS_VIDEO_SPINNER_ACTOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BACON_TYPE_VIDEO_SPINNER_ACTOR)) -#define BACON_IS_VIDEO_SPINNER_ACTOR_CLASS(klass) (G_TYPE_INSTANCE_GET_CLASS ((klass), BACON_TYPE_VIDEO_SPINNER_ACTOR)) -#define BACON_VIDEO_SPINNER_ACTOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BACON_TYPE_VIDEO_SPINNER_ACTOR, BaconVideoSpinnerActorClass)) - -typedef struct BaconVideoSpinnerActor BaconVideoSpinnerActor; -typedef struct BaconVideoSpinnerActorClass BaconVideoSpinnerActorClass; -typedef struct BaconVideoSpinnerActorPrivate BaconVideoSpinnerActorPrivate; - -struct BaconVideoSpinnerActor { - ClutterActor parent; - - BaconVideoSpinnerActorPrivate *priv; -}; - -struct BaconVideoSpinnerActorClass { - ClutterActorClass parent_class; -}; - -GType bacon_video_spinner_actor_get_type (void); - -ClutterActor * bacon_video_spinner_actor_new (void); - -G_END_DECLS - -#endif diff --git a/src/backend/clock.c b/src/backend/clock.c deleted file mode 100644 index 533af4602..000000000 --- a/src/backend/clock.c +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright © 2013 Red Hat, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. - * - * Author: Joaquim Rocha <me@joaquimrocha.com> - */ - -#include <math.h> -#include "clock.h" - -#define CLOCK_RADIUS 150 -#define CLOCK_LINE_WIDTH 40 -#define CLOCK_LINE_PADDING 10 -#define ANGLE_PROP_NAME "angle" - -G_DEFINE_TYPE (Clock, clock, CLUTTER_TYPE_ACTOR); - -enum { - PROP_0, - PROP_ANGLE, - N_PROPERTIES -}; - -static GParamSpec *obj_properties[N_PROPERTIES] = { NULL, }; - -static void -draw_clock (ClutterCairoTexture *texture, - cairo_t *cr, - gint width, - gint height, - Clock *self) -{ - cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR); - cairo_paint (cr); - - cairo_set_operator (cr, CAIRO_OPERATOR_OVER); - - /* Draw the clock background */ - cairo_arc(cr, width / 2, height / 2, CLOCK_RADIUS / 2, 0.0, 2.0 * M_PI); - cairo_set_source_rgb(cr, 0.5, 0.5, 0.5); - cairo_fill_preserve(cr); - cairo_stroke(cr); - - cairo_set_line_width(cr, CLOCK_LINE_WIDTH); - - cairo_arc(cr, - width / 2, - height / 2, - (CLOCK_RADIUS - CLOCK_LINE_WIDTH - CLOCK_LINE_PADDING) / 2, - 3 * M_PI_2, - 3 * M_PI_2 + self->angle * M_PI / 180.0); - cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); - cairo_stroke(cr); -} - -static void -clock_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - Clock *self = CLOCK (object); - ClutterContent *content; - content = clutter_actor_get_content (CLUTTER_ACTOR (self)); - - switch (property_id) - { - case PROP_ANGLE: - self->angle = g_value_get_float (value); - if (content) - clutter_content_invalidate (content); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -static void -clock_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - Clock *self = CLOCK (object); - - switch (property_id) - { - case PROP_ANGLE: - g_value_set_float (value, self->angle); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -static void -clock_init (Clock *self) -{ - ClutterContent *content; - - self->angle = 0; - - content = clutter_canvas_new (); - clutter_canvas_set_size (CLUTTER_CANVAS (content), - CLOCK_RADIUS + 2, - CLOCK_RADIUS + 2); - clutter_actor_set_content (CLUTTER_ACTOR (self), content); - g_signal_connect (CLUTTER_CANVAS (content), - "draw", - G_CALLBACK (draw_clock), - self); - g_object_unref (content); -} - -static void -clock_get_preferred_width (ClutterActor *actor, - gfloat for_height, - gfloat *min_width_p, - gfloat *natural_width_p) -{ - *min_width_p = CLOCK_RADIUS + 2; - *natural_width_p = CLOCK_RADIUS + 2; -} - -static void -clock_get_preferred_height (ClutterActor *actor, - gfloat for_width, - gfloat *min_height_p, - gfloat *natural_height_p) -{ - *min_height_p = CLOCK_RADIUS + 2; - *natural_height_p = CLOCK_RADIUS + 2; -} - - -static void -clock_class_init (ClockClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - ClutterActorClass *clutter_actor_class = CLUTTER_ACTOR_CLASS (klass); - - gobject_class->set_property = clock_set_property; - gobject_class->get_property = clock_get_property; - - clutter_actor_class->get_preferred_width = clock_get_preferred_width; - clutter_actor_class->get_preferred_height = clock_get_preferred_height; - - obj_properties[PROP_ANGLE] = - g_param_spec_float (ANGLE_PROP_NAME, - "The angle of the clock's progress", - "Set the angle of the clock's progress", - .0, - 360.0, - .0, - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS); - - g_object_class_install_properties (gobject_class, - N_PROPERTIES, - obj_properties); -} - -ClutterActor * -clock_new (void) -{ - return g_object_new (CLOCK_TYPE, NULL); -} diff --git a/src/backend/clock.h b/src/backend/clock.h deleted file mode 100644 index a9053a36e..000000000 --- a/src/backend/clock.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright © 2013 Red Hat, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see <http://www.gnu.org/licenses/>. - * - * Author: Joaquim Rocha <me@joaquimrocha.com> - */ - -#ifndef __CLOCK_H__ -#define __CLOCK_H__ - -#include <glib.h> -#include <clutter/clutter.h> - -G_BEGIN_DECLS - -#define CLOCK_TYPE (clock_get_type ()) -#define CLOCK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLOCK_TYPE, Clock)) -#define CLOCK_IS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLOCK_TYPE)) -#define CLOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLOCK_TYPE, ClockClass)) -#define CLOCK_IS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLOCK_TYPE)) -#define CLOCK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLOCK_TYPE, ClockClass)) - -typedef struct _Clock Clock; -typedef struct _ClockClass ClockClass; - -struct _Clock -{ - ClutterActor parent_instance; - - /*< private >*/ - gfloat angle; -}; - -struct _ClockClass -{ - ClutterActorClass parent_class; -}; - -ClutterActor * clock_new (void); - -GType clock_get_type (void); - -#endif /* __CLOCK_H__ */ diff --git a/src/backend/totem-aspect-frame.c b/src/backend/totem-aspect-frame.c deleted file mode 100644 index 19d75ee31..000000000 --- a/src/backend/totem-aspect-frame.c +++ /dev/null @@ -1,456 +0,0 @@ -/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ -/* - * A container that respects the aspect ratio of its child - * - * Copyright 2010, 2011 Intel Corporation. - * Copyright 2012, Red Hat, Inc. - * - * Based upon mx-aspect-frame.c - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU Lesser General Public License, - * version 2.1, as published by the Free Software Foundation. - * - * This program is distributed in the hope 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 program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * Boston, MA 02111-1307, USA. - */ - -#include <math.h> - -#include "totem-aspect-frame.h" - -enum -{ - PROP_0, - - PROP_EXPAND, -}; - -struct _TotemAspectFramePrivate -{ - guint expand : 1; - gdouble rotation; -}; - -G_DEFINE_TYPE_WITH_PRIVATE (TotemAspectFrame, totem_aspect_frame, CLUTTER_TYPE_ACTOR) - - -static void -totem_aspect_frame_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - TotemAspectFrame *frame = TOTEM_ASPECT_FRAME (object); - - switch (property_id) - { - case PROP_EXPAND: - g_value_set_boolean (value, totem_aspect_frame_get_expand (frame)); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - } -} - -static void -totem_aspect_frame_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - switch (property_id) - { - case PROP_EXPAND: - totem_aspect_frame_set_expand (TOTEM_ASPECT_FRAME (object), - g_value_get_boolean (value)); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - } -} - -static void -totem_aspect_frame_dispose (GObject *object) -{ - G_OBJECT_CLASS (totem_aspect_frame_parent_class)->dispose (object); -} - -static void -totem_aspect_frame_finalize (GObject *object) -{ - G_OBJECT_CLASS (totem_aspect_frame_parent_class)->finalize (object); -} - -static void -totem_aspect_frame_get_preferred_width (ClutterActor *actor, - gfloat for_height, - gfloat *min_width_p, - gfloat *nat_width_p) -{ - gboolean override; - - if (for_height >= 0) - override = FALSE; - else - g_object_get (G_OBJECT (actor), "natural-height-set", &override, NULL); - - if (override) - g_object_get (G_OBJECT (actor), "natural-height", &for_height, NULL); - - CLUTTER_ACTOR_CLASS (totem_aspect_frame_parent_class)-> - get_preferred_width (actor, for_height, min_width_p, nat_width_p); -} - -static void -totem_aspect_frame_get_preferred_height (ClutterActor *actor, - gfloat for_width, - gfloat *min_height_p, - gfloat *nat_height_p) -{ - gboolean override; - - if (for_width >= 0) - override = FALSE; - else - g_object_get (G_OBJECT (actor), "natural-width-set", &override, NULL); - - if (override) - g_object_get (G_OBJECT (actor), "natural-width", &for_width, NULL); - - CLUTTER_ACTOR_CLASS (totem_aspect_frame_parent_class)-> - get_preferred_height (actor, for_width, min_height_p, nat_height_p); -} - -static void -totem_aspect_frame_get_size (TotemAspectFrame *frame, - gdouble rotation, - gfloat *width, - gfloat *height) -{ - ClutterActorBox box; - gfloat w, h; - - clutter_actor_get_allocation_box (CLUTTER_ACTOR (frame), &box); - - if (fmod (rotation, 180.0) == 90.0) - { - w = box.y2 - box.y1; - h = box.x2 - box.x1; - } - else - { - w = box.x2 - box.x1; - h = box.y2 - box.y1; - } - - if (width) - *width = w; - if (height) - *height = h; -} - -static void -_get_allocation (ClutterActor *actor, - gfloat *width, - gfloat *height) -{ - ClutterActorBox box; - - clutter_actor_get_allocation_box (actor, &box); - - if (width) - *width = box.x2 - box.x1; - if (height) - *height = box.y2 - box.y1; -} - -static void -totem_aspect_frame_set_rotation_internal (TotemAspectFrame *frame, - gdouble rotation, - gboolean animate) -{ - TotemAspectFramePrivate *priv = frame->priv; - ClutterActor *actor; - gfloat frame_width, frame_height; - gfloat child_width, child_height; - gfloat child_dest_width, child_dest_height; - gdouble frame_aspect; - gdouble child_aspect; - - actor = clutter_actor_get_child_at_index (CLUTTER_ACTOR (frame), 0); - if (!actor) - return; - - totem_aspect_frame_get_size (frame, rotation, - &frame_width, &frame_height); - _get_allocation (actor, &child_width, &child_height); - - if (child_width <= 0.0f || child_height <= 0.0f) - return; - - frame_aspect = frame_width / frame_height; - child_aspect = child_width / child_height; - - if ((frame_aspect < child_aspect) ^ priv->expand) - { - child_dest_width = frame_width; - child_dest_height = frame_width / child_aspect; - } - else - { - child_dest_height = frame_height; - child_dest_width = frame_height * child_aspect; - } - - clutter_actor_set_pivot_point (actor, 0.5, 0.5); - - if (animate) - { - clutter_actor_save_easing_state (actor); - clutter_actor_set_easing_duration (actor, 500); - } - - clutter_actor_set_rotation_angle (actor, CLUTTER_Z_AXIS, rotation); - clutter_actor_set_scale (actor, - child_dest_width / child_width, - child_dest_height / child_height); - - if (animate) - clutter_actor_restore_easing_state (actor); -} - -static void -totem_aspect_frame_allocate (ClutterActor *actor, - const ClutterActorBox *box, - ClutterAllocationFlags flags) -{ - ClutterActor *child; - ClutterActorBox child_box; - gfloat aspect, child_aspect, width, height, box_width, box_height; - - TotemAspectFramePrivate *priv = TOTEM_ASPECT_FRAME (actor)->priv; - - CLUTTER_ACTOR_CLASS (totem_aspect_frame_parent_class)-> - allocate (actor, box, flags); - - child = clutter_actor_get_child_at_index (actor, 0); - if (!child) - return; - - box_width = box->x2 - box->x1; - box_height = box->y2 - box->y1; - - clutter_actor_get_preferred_size (child, NULL, NULL, &width, &height); - - if (width <= 0.0f || height <= 0.0f) - return; - - aspect = box_width / box_height; - child_aspect = width / height; - - if ((aspect < child_aspect) ^ priv->expand) - { - width = box_width; - height = box_width / child_aspect; - } - else - { - height = box_height; - width = box_height * child_aspect; - } - - child_box.x1 = (box_width - width) / 2; - child_box.y1 = (box_height - height) / 2; - child_box.x2 = child_box.x1 + width; - child_box.y2 = child_box.y1 + height; - - clutter_actor_allocate (child, &child_box, flags); - - totem_aspect_frame_set_rotation_internal (TOTEM_ASPECT_FRAME (actor), - priv->rotation, FALSE); -} - -static void -totem_aspect_frame_paint (ClutterActor *actor) -{ - ClutterActor *child; - TotemAspectFramePrivate *priv = TOTEM_ASPECT_FRAME (actor)->priv; - - child = clutter_actor_get_child_at_index (actor, 0); - - if (!child) - return; - - if (priv->expand) - { - gfloat width, height; - - clutter_actor_get_size (actor, &width, &height); - - cogl_clip_push_rectangle (0.0, 0.0, width, height); - clutter_actor_paint (child); - cogl_clip_pop (); - } - else - clutter_actor_paint (child); -} - -static void -totem_aspect_frame_pick (ClutterActor *actor, - const ClutterColor *color) -{ - ClutterActorBox box; - ClutterActor *child; - TotemAspectFramePrivate *priv = TOTEM_ASPECT_FRAME (actor)->priv; - - clutter_actor_get_allocation_box (actor, &box); - - CLUTTER_ACTOR_CLASS (totem_aspect_frame_parent_class)->pick (actor, color); - - child = clutter_actor_get_child_at_index (actor, 0); - - if (!child) - return; - - if (priv->expand) - { - cogl_clip_push_rectangle (0.0, 0.0, box.x2 - box.x1, box.y2 - box.y1); - clutter_actor_paint (child); - cogl_clip_pop (); - } - else - clutter_actor_paint (child); -} - -static void -totem_aspect_frame_class_init (TotemAspectFrameClass *klass) -{ - GParamSpec *pspec; - - GObjectClass *object_class = G_OBJECT_CLASS (klass); - ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass); - - object_class->get_property = totem_aspect_frame_get_property; - object_class->set_property = totem_aspect_frame_set_property; - object_class->dispose = totem_aspect_frame_dispose; - object_class->finalize = totem_aspect_frame_finalize; - - actor_class->get_preferred_width = totem_aspect_frame_get_preferred_width; - actor_class->get_preferred_height = totem_aspect_frame_get_preferred_height; - actor_class->allocate = totem_aspect_frame_allocate; - actor_class->paint = totem_aspect_frame_paint; - actor_class->pick = totem_aspect_frame_pick; - - pspec = g_param_spec_boolean ("expand", - "Expand", - "Fill the allocated area with the child and " - "clip off the excess.", - FALSE, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, PROP_EXPAND, pspec); -} - -static void -totem_aspect_frame_init (TotemAspectFrame *self) -{ - self->priv = totem_aspect_frame_get_instance_private (self); - clutter_actor_set_pivot_point (CLUTTER_ACTOR (self), 0.5f, 0.5f); -} - -ClutterActor * -totem_aspect_frame_new (void) -{ - return g_object_new (TOTEM_TYPE_ASPECT_FRAME, NULL); -} - -void -totem_aspect_frame_set_expand (TotemAspectFrame *frame, gboolean expand) -{ - TotemAspectFramePrivate *priv; - - g_return_if_fail (TOTEM_IS_ASPECT_FRAME (frame)); - - priv = frame->priv; - if (priv->expand != expand) - { - priv->expand = expand; - g_object_notify (G_OBJECT (frame), "expand"); - - totem_aspect_frame_set_rotation_internal (frame, priv->rotation, TRUE); - } -} - -gboolean -totem_aspect_frame_get_expand (TotemAspectFrame *frame) -{ - g_return_val_if_fail (TOTEM_IS_ASPECT_FRAME (frame), FALSE); - return frame->priv->expand; -} - -void -totem_aspect_frame_set_child (TotemAspectFrame *frame, - ClutterActor *child) -{ - g_return_if_fail (TOTEM_IS_ASPECT_FRAME (frame)); - - clutter_actor_add_child (CLUTTER_ACTOR (frame), child); -} - -void -totem_aspect_frame_set_rotation (TotemAspectFrame *frame, - gdouble rotation) -{ - g_return_if_fail (TOTEM_IS_ASPECT_FRAME (frame)); - g_return_if_fail (fmod (rotation, 90.0) == 0.0); - - rotation = fmod (rotation, 360.0); - - /* When animating, make sure that we go in the right direction, - * otherwise we'll spin in the wrong direction going back to 0 from 270 */ - if (rotation == 0.0 && frame->priv->rotation == 270.0) - rotation = 360.0; - else if (rotation == 90.0 && frame->priv->rotation == 360.0) - totem_aspect_frame_set_rotation_internal (frame, 0.0, FALSE); - else if (rotation == 270.0 && fmod (frame->priv->rotation, 360.0) == 0.0) - totem_aspect_frame_set_rotation_internal (frame, 360.0, FALSE); - - g_debug ("Setting rotation to '%lf'", rotation); - - frame->priv->rotation = rotation; - totem_aspect_frame_set_rotation_internal (frame, rotation, TRUE); -} - -void -totem_aspect_frame_set_internal_rotation (TotemAspectFrame *frame, - gdouble rotation) -{ - g_return_if_fail (TOTEM_IS_ASPECT_FRAME (frame)); - - rotation = fmod (rotation, 360.0); - - frame->priv->rotation = rotation; - totem_aspect_frame_set_rotation_internal (frame, rotation, FALSE); -} - -gdouble -totem_aspect_frame_get_rotation (TotemAspectFrame *frame) -{ - gdouble rotation; - - g_return_val_if_fail (TOTEM_IS_ASPECT_FRAME (frame), 0.0); - - rotation = fmod (frame->priv->rotation, 360.0); - g_debug ("Got rotation %lf", rotation); - - return rotation; -} diff --git a/src/backend/totem-aspect-frame.h b/src/backend/totem-aspect-frame.h deleted file mode 100644 index 3371cf813..000000000 --- a/src/backend/totem-aspect-frame.h +++ /dev/null @@ -1,90 +0,0 @@ - -/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ -/* - * mx-aspect-frame.h: A container that respect the aspect ratio of its child - * - * Copyright 2010, 2011 Intel Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU Lesser General Public License, - * version 2.1, as published by the Free Software Foundation. - * - * This program is distributed in the hope 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 program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * Boston, MA 02111-1307, USA. - * - */ - -#ifndef __TOTEM_ASPECT_FRAME_H__ -#define __TOTEM_ASPECT_FRAME_H__ - -#include <glib-object.h> -#include <clutter/clutter.h> - -G_BEGIN_DECLS - -#define TOTEM_TYPE_ASPECT_FRAME totem_aspect_frame_get_type() - -#define TOTEM_ASPECT_FRAME(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - TOTEM_TYPE_ASPECT_FRAME, TotemAspectFrame)) - -#define TOTEM_ASPECT_FRAME_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), \ - TOTEM_TYPE_ASPECT_FRAME, TotemAspectFrameClass)) - -#define TOTEM_IS_ASPECT_FRAME(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ - TOTEM_TYPE_ASPECT_FRAME)) - -#define TOTEM_IS_ASPECT_FRAME_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), \ - TOTEM_TYPE_ASPECT_FRAME)) - -#define TOTEM_ASPECT_FRAME_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), \ - TOTEM_TYPE_ASPECT_FRAME, TotemAspectFrameClass)) - -typedef struct _TotemAspectFrame TotemAspectFrame; -typedef struct _TotemAspectFrameClass TotemAspectFrameClass; -typedef struct _TotemAspectFramePrivate TotemAspectFramePrivate; - -struct _TotemAspectFrame -{ - ClutterActor parent; - - TotemAspectFramePrivate *priv; -}; - -struct _TotemAspectFrameClass -{ - ClutterActorClass parent_class; -}; - -GType totem_aspect_frame_get_type (void) G_GNUC_CONST; - -ClutterActor * totem_aspect_frame_new (void); - -void totem_aspect_frame_set_child (TotemAspectFrame *frame, - ClutterActor *child); - -void totem_aspect_frame_set_expand (TotemAspectFrame *frame, - gboolean expand); -gboolean totem_aspect_frame_get_expand (TotemAspectFrame *frame); - -void totem_aspect_frame_set_rotation (TotemAspectFrame *frame, - gdouble rotation); -void totem_aspect_frame_set_internal_rotation - (TotemAspectFrame *frame, - gdouble rotation); -gdouble totem_aspect_frame_get_rotation (TotemAspectFrame *frame); - -G_END_DECLS - -#endif /* __TOTEM_ASPECT_FRAME_H__ */ |