[totem] main: Move OSD to the backend
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [totem] main: Move OSD to the backend
- Date: Wed, 18 Apr 2012 16:08:54 +0000 (UTC)
commit dec73a90ca4fe302885dd3c2c5f694df92974b66
Author: Bastien Nocera <hadess hadess net>
Date: Wed Apr 18 16:54:26 2012 +0100
main: Move OSD to the backend
And use Clutter to draw it.
src/Makefile.am | 3 -
src/backend/Makefile.am | 7 +-
src/backend/bacon-video-osd-actor.c | 254 ++++++++++++++++++++++++++++
src/backend/bacon-video-osd-actor.h | 70 ++++++++
src/backend/bacon-video-widget-gst-0.10.c | 35 ++++-
src/backend/bacon-video-widget.h | 4 +
src/{ => backend}/gsd-osd-window-private.h | 3 +
src/{ => backend}/gsd-osd-window.c | 26 ++--
src/{ => backend}/gsd-osd-window.h | 7 -
src/totem-fullscreen.c | 37 +----
10 files changed, 381 insertions(+), 65 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index fb99218..b70afec 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -42,9 +42,6 @@ libtotem_player_la_SOURCES = \
totem-fullscreen.h \
gd-fullscreen-filter.c \
gd-fullscreen-filter.h \
- gsd-osd-window.c \
- gsd-osd-window.h \
- gsd-osd-window-private.h\
totem-time-label.c \
totem-time-label.h
diff --git a/src/backend/Makefile.am b/src/backend/Makefile.am
index ef9fcf3..c03c192 100644
--- a/src/backend/Makefile.am
+++ b/src/backend/Makefile.am
@@ -55,7 +55,12 @@ libbaconvideowidget_la_SOURCES = \
bacon-video-widget-gst-missing-plugins.c \
bacon-video-widget-gst-missing-plugins.h \
totem-aspect-frame.h \
- totem-aspect-frame.c
+ totem-aspect-frame.c \
+ gsd-osd-window.c \
+ gsd-osd-window.h \
+ gsd-osd-window-private.h \
+ bacon-video-osd-actor.c \
+ bacon-video-osd-actor.h
libbaconvideowidget_la_CPPFLAGS = \
-D_REENTRANT \
diff --git a/src/backend/bacon-video-osd-actor.c b/src/backend/bacon-video-osd-actor.c
new file mode 100644
index 0000000..0a88dcd
--- /dev/null
+++ b/src/backend/bacon-video-osd-actor.c
@@ -0,0 +1,254 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * On-screen-display (OSD) for Totem's video widget
+ *
+ * Copyright (C) 2012 Red Hat, Inc.
+ *
+ * Authors:
+ * 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, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <clutter/clutter.h>
+#include <gtk/gtk.h>
+
+#include "bacon-video-osd-actor.h"
+#include "gsd-osd-window.h"
+#include "gsd-osd-window-private.h"
+
+#define BACON_VIDEO_OSD_ACTOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), BACON_TYPE_VIDEO_OSD_ACTOR, BaconVideoOsdActorPrivate))
+
+struct BaconVideoOsdActorPrivate
+{
+ ClutterCanvas *canvas;
+ char *icon_name;
+ GtkStyleContext *style;
+ GsdOsdDrawContext *ctx;
+
+ guint hide_timeout_id;
+ guint fade_timeout_id;
+ double fade_out_alpha;
+};
+
+G_DEFINE_TYPE (BaconVideoOsdActor, bacon_video_osd_actor, CLUTTER_TYPE_ACTOR);
+
+static gboolean
+fade_timeout (BaconVideoOsdActor *osd)
+{
+ if (osd->priv->fade_out_alpha <= 0.0) {
+ bacon_video_osd_actor_hide (osd);
+ return FALSE;
+ } else {
+ clutter_actor_set_opacity (CLUTTER_ACTOR (osd),
+ 0xff * osd->priv->fade_out_alpha);
+ osd->priv->fade_out_alpha -= 0.10;
+ }
+
+ return TRUE;
+}
+
+static gboolean
+hide_timeout (BaconVideoOsdActor *osd)
+{
+ osd->priv->hide_timeout_id = 0;
+ osd->priv->fade_timeout_id = g_timeout_add (FADE_FRAME_TIMEOUT,
+ (GSourceFunc) fade_timeout,
+ osd);
+
+ return FALSE;
+}
+
+static void
+remove_hide_timeout (BaconVideoOsdActor *osd)
+{
+ if (osd->priv->hide_timeout_id != 0) {
+ g_source_remove (osd->priv->hide_timeout_id);
+ osd->priv->hide_timeout_id = 0;
+ }
+
+ if (osd->priv->fade_timeout_id != 0) {
+ g_source_remove (osd->priv->fade_timeout_id);
+ osd->priv->fade_timeout_id = 0;
+ osd->priv->fade_out_alpha = 1.0;
+ }
+}
+
+static void
+add_hide_timeout (BaconVideoOsdActor *osd)
+{
+ osd->priv->hide_timeout_id = g_timeout_add (DIALOG_FADE_TIMEOUT,
+ (GSourceFunc) hide_timeout,
+ osd);
+}
+
+static void
+bacon_video_osd_actor_finalize (GObject *object)
+{
+ BaconVideoOsdActor *osd;
+
+ osd = BACON_VIDEO_OSD_ACTOR (object);
+ if (osd->priv->ctx) {
+ g_free (osd->priv->ctx);
+ osd->priv->ctx = NULL;
+ }
+ if (osd->priv->style) {
+ g_object_unref (osd->priv->style);
+ osd->priv->style = NULL;
+ }
+
+ g_free (osd->priv->icon_name);
+ osd->priv->icon_name = NULL;
+
+ G_OBJECT_CLASS (bacon_video_osd_actor_parent_class)->finalize (object);
+}
+
+static void
+bacon_video_osd_actor_class_init (BaconVideoOsdActorClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+// gobject_class->constructor = bacon_video_osd_actor_constructor;
+ gobject_class->finalize = bacon_video_osd_actor_finalize;
+
+ g_type_class_add_private (klass, sizeof (BaconVideoOsdActorPrivate));
+}
+
+static gboolean
+bacon_video_osd_actor_draw (ClutterCanvas *canvas,
+ cairo_t *cr,
+ int width,
+ int height,
+ BaconVideoOsdActor *osd)
+{
+ GsdOsdDrawContext *ctx;
+
+ g_return_val_if_fail (osd->priv->icon_name != NULL, FALSE);
+
+ ctx = osd->priv->ctx;
+
+ cairo_save (cr);
+ cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
+ cairo_paint (cr);
+
+ cairo_restore (cr);
+ cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
+
+ ctx->size = MIN(width, height);
+ ctx->icon_name = osd->priv->icon_name;
+
+ gsd_osd_window_draw (ctx, cr);
+
+ return FALSE;
+}
+
+static void
+bacon_video_osd_actor_init (BaconVideoOsdActor *osd)
+{
+ ClutterActor *self;
+ GtkWidgetPath *widget_path;
+
+ self = CLUTTER_ACTOR (osd);
+ osd->priv = BACON_VIDEO_OSD_ACTOR_GET_PRIVATE (osd);
+
+ osd->priv->canvas = CLUTTER_CANVAS (clutter_canvas_new ());
+ g_object_bind_property (self, "width",
+ osd->priv->canvas, "width",
+ G_BINDING_DEFAULT);
+ g_object_bind_property (self, "height",
+ osd->priv->canvas, "height",
+ G_BINDING_DEFAULT);
+ clutter_actor_set_content (self, CLUTTER_CONTENT (osd->priv->canvas));
+ g_object_unref (osd->priv->canvas);
+
+ osd->priv->icon_name = g_strdup ("media-playback-pause-symbolic");
+
+ osd->priv->ctx = g_new0 (GsdOsdDrawContext, 1);
+
+ widget_path = gtk_widget_path_new ();
+ gtk_widget_path_append_type (widget_path, GTK_TYPE_WINDOW);
+ osd->priv->style = gtk_style_context_new ();
+ gtk_style_context_set_path (osd->priv->style, widget_path);
+ gtk_widget_path_free (widget_path);
+
+ osd->priv->ctx->direction = clutter_get_default_text_direction ();
+ osd->priv->ctx->theme = gtk_icon_theme_get_default ();
+ osd->priv->ctx->action = GSD_OSD_WINDOW_ACTION_CUSTOM;
+ osd->priv->ctx->style = osd->priv->style;
+
+ g_signal_connect (osd->priv->canvas, "draw", G_CALLBACK (bacon_video_osd_actor_draw), osd);
+ osd->priv->fade_out_alpha = 1.0;
+}
+
+ClutterActor *
+bacon_video_osd_actor_new (void)
+{
+ return g_object_new (BACON_TYPE_VIDEO_OSD_ACTOR, NULL);
+}
+
+void
+bacon_video_osd_actor_set_icon_name (BaconVideoOsdActor *osd,
+ const char *icon_name)
+{
+ g_return_if_fail (BACON_IS_VIDEO_OSD_ACTOR (osd));
+
+ g_free (osd->priv->icon_name);
+ osd->priv->icon_name = g_strdup (icon_name);
+
+ if (icon_name != NULL)
+ clutter_content_invalidate (CLUTTER_CONTENT (osd->priv->canvas));
+}
+
+void
+bacon_video_osd_actor_hide (BaconVideoOsdActor *osd)
+{
+ g_return_if_fail (BACON_IS_VIDEO_OSD_ACTOR (osd));
+
+ clutter_actor_hide (CLUTTER_ACTOR (osd));
+
+ /* Reset it for the next time */
+ osd->priv->fade_out_alpha = 1.0;
+ osd->priv->fade_timeout_id = 0;
+}
+
+void
+bacon_video_osd_actor_show (BaconVideoOsdActor *osd)
+{
+ g_return_if_fail (BACON_IS_VIDEO_OSD_ACTOR (osd));
+
+ remove_hide_timeout (osd);
+ clutter_actor_set_opacity (CLUTTER_ACTOR (osd), 0xff);
+ clutter_actor_show (CLUTTER_ACTOR (osd));
+}
+
+void
+bacon_video_osd_actor_show_and_fade (BaconVideoOsdActor *osd)
+{
+ g_return_if_fail (BACON_IS_VIDEO_OSD_ACTOR (osd));
+
+ remove_hide_timeout (osd);
+ clutter_actor_set_opacity (CLUTTER_ACTOR (osd), 0xff);
+ clutter_actor_show (CLUTTER_ACTOR (osd));
+ add_hide_timeout (osd);
+}
diff --git a/src/backend/bacon-video-osd-actor.h b/src/backend/bacon-video-osd-actor.h
new file mode 100644
index 0000000..dd8f165
--- /dev/null
+++ b/src/backend/bacon-video-osd-actor.h
@@ -0,0 +1,70 @@
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8; tab-width: 8 -*-
+ *
+ * On-screen-display (OSD) window for gnome-settings-daemon's plugins
+ *
+ * Copyright (C) 2006 William Jon McCann <mccann jhu edu>
+ * Copyright (C) 2009 Novell, Inc
+ *
+ * Authors:
+ * William Jon McCann <mccann jhu edu>
+ * Federico Mena-Quintero <federico novell com>
+ *
+ * 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, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef BACON_VIDEO_OSD_ACTOR_H
+#define BACON_VIDEO_OSD_ACTOR_H
+
+#include <glib-object.h>
+#include <clutter/clutter.h>
+
+G_BEGIN_DECLS
+
+#define BACON_TYPE_VIDEO_OSD_ACTOR (bacon_video_osd_actor_get_type ())
+#define BACON_VIDEO_OSD_ACTOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BACON_TYPE_VIDEO_OSD_ACTOR, BaconVideoOsdActor))
+#define BACON_VIDEO_OSD_ACTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BACON_TYPE_VIDEO_OSD_ACTOR, BaconVideoOsdActorClass))
+#define BACON_IS_VIDEO_OSD_ACTOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BACON_TYPE_VIDEO_OSD_ACTOR))
+#define BACON_IS_VIDEO_OSD_ACTOR_CLASS(klass) (G_TYPE_INSTANCE_GET_CLASS ((klass), BACON_TYPE_VIDEO_OSD_ACTOR))
+#define BACON_VIDEO_OSD_ACTOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BACON_TYPE_VIDEO_OSD_ACTOR, BaconVideoOsdActorClass))
+
+typedef struct BaconVideoOsdActor BaconVideoOsdActor;
+typedef struct BaconVideoOsdActorClass BaconVideoOsdActorClass;
+typedef struct BaconVideoOsdActorPrivate BaconVideoOsdActorPrivate;
+
+struct BaconVideoOsdActor {
+ ClutterActor parent;
+
+ BaconVideoOsdActorPrivate *priv;
+};
+
+struct BaconVideoOsdActorClass {
+ ClutterActorClass parent_class;
+};
+
+GType bacon_video_osd_actor_get_type (void);
+
+ClutterActor * bacon_video_osd_actor_new (void);
+void bacon_video_osd_actor_set_icon_name (BaconVideoOsdActor *osd,
+ const char *icon_name);
+void bacon_video_osd_actor_hide (BaconVideoOsdActor *osd);
+void bacon_video_osd_actor_show (BaconVideoOsdActor *osd);
+void bacon_video_osd_actor_show_and_fade (BaconVideoOsdActor *osd);
+
+G_END_DECLS
+
+#endif
diff --git a/src/backend/bacon-video-widget-gst-0.10.c b/src/backend/bacon-video-widget-gst-0.10.c
index cef1413..4f79bcc 100644
--- a/src/backend/bacon-video-widget-gst-0.10.c
+++ b/src/backend/bacon-video-widget-gst-0.10.c
@@ -85,18 +85,22 @@
#include "totem-gst-helpers.h"
#include "bacon-video-widget.h"
#include "bacon-video-widget-gst-missing-plugins.h"
+#include "bacon-video-osd-actor.h"
#include "baconvideowidget-marshal.h"
#include "bacon-video-widget-enums.h"
#include "video-utils.h"
#define DEFAULT_USER_AGENT "Totem/"VERSION
-#define FORWARD_RATE 1.0
-#define REVERSE_RATE -1.0
-/* Maximum size of the logo */
-#define LOGO_SIZE 256
+#define OSD_SIZE 130 /* Size of the OSD popup */
+#define OSD_MARGIN 8 /* Pixels from the top-left */
+#define LOGO_SIZE 256 /* Maximum size of the logo */
+
+/* Helper constants */
#define NANOSECS_IN_SEC 1000000000
#define SEEK_TIMEOUT NANOSECS_IN_SEC / 10
+#define FORWARD_RATE 1.0
+#define REVERSE_RATE -1.0
#define is_error(e, d, c) \
(e->domain == GST_##d##_ERROR && \
@@ -198,6 +202,7 @@ struct BaconVideoWidgetPrivate
ClutterActor *stage;
ClutterActor *texture;
ClutterActor *frame;
+ ClutterActor *osd;
ClutterActor *logo_frame;
ClutterActor *logo;
@@ -3277,6 +3282,18 @@ bacon_video_widget_set_audio_output_type (BaconVideoWidget *bvw,
set_audio_filter (bvw);
}
+void
+bacon_video_widget_popup_osd (BaconVideoWidget *bvw,
+ const char *icon_name)
+{
+ g_return_if_fail (bvw != NULL);
+ g_return_if_fail (BACON_IS_VIDEO_WIDGET (bvw));
+
+ bacon_video_osd_actor_set_icon_name (BACON_VIDEO_OSD_ACTOR (bvw->priv->osd),
+ icon_name);
+ bacon_video_osd_actor_show_and_fade (BACON_VIDEO_OSD_ACTOR (bvw->priv->osd));
+}
+
/* =========================================== */
/* */
/* Play/Pause, Stop */
@@ -5969,6 +5986,16 @@ bacon_video_widget_initable_init (GInitable *initable,
CLUTTER_ACTOR (bvw->priv->logo_frame),
CLUTTER_ACTOR (bvw->priv->frame));
+ /* The OSD */
+ bvw->priv->osd = bacon_video_osd_actor_new ();
+ clutter_actor_set_anchor_point (bvw->priv->osd, -OSD_MARGIN, -OSD_MARGIN); /* FIXME RTL */
+ clutter_actor_set_size (bvw->priv->osd, OSD_SIZE, OSD_SIZE);
+ clutter_actor_add_child (bvw->priv->stage, bvw->priv->osd);
+ clutter_actor_set_child_above_sibling (bvw->priv->stage,
+ bvw->priv->osd,
+ bvw->priv->frame);
+ bacon_video_osd_actor_hide (BACON_VIDEO_OSD_ACTOR (bvw->priv->osd));
+
/* Add video balance */
balance = gst_element_factory_make ("videobalance", "video_balance");
gst_bin_add (GST_BIN (bin), balance);
diff --git a/src/backend/bacon-video-widget.h b/src/backend/bacon-video-widget.h
index 0b3609b..6d7f4d1 100644
--- a/src/backend/bacon-video-widget.h
+++ b/src/backend/bacon-video-widget.h
@@ -497,6 +497,10 @@ BvwAudioOutputType bacon_video_widget_get_audio_output_type
void bacon_video_widget_set_audio_output_type (BaconVideoWidget *bvw,
BvwAudioOutputType type);
+/* OSD */
+void bacon_video_widget_popup_osd (BaconVideoWidget *bvw,
+ const char *icon_name);
+
G_END_DECLS
#endif /* HAVE_BACON_VIDEO_WIDGET_H */
diff --git a/src/gsd-osd-window-private.h b/src/backend/gsd-osd-window-private.h
similarity index 93%
rename from src/gsd-osd-window-private.h
rename to src/backend/gsd-osd-window-private.h
index de3b2af..b922ed4 100644
--- a/src/gsd-osd-window-private.h
+++ b/src/backend/gsd-osd-window-private.h
@@ -46,6 +46,9 @@
G_BEGIN_DECLS
+#define DIALOG_FADE_TIMEOUT 1500 /* timeout before fade starts */
+#define FADE_FRAME_TIMEOUT 10 /* timeout in ms between each frame of the fade */
+
typedef struct {
int size;
GtkStyleContext *style;
diff --git a/src/gsd-osd-window.c b/src/backend/gsd-osd-window.c
similarity index 97%
rename from src/gsd-osd-window.c
rename to src/backend/gsd-osd-window.c
index 1206c2e..1849948 100644
--- a/src/gsd-osd-window.c
+++ b/src/backend/gsd-osd-window.c
@@ -40,11 +40,9 @@
#include "gsd-osd-window.h"
#include "gsd-osd-window-private.h"
-#define DIALOG_TIMEOUT 2000 /* dialog timeout in ms */
-#define DIALOG_FADE_TIMEOUT 1500 /* timeout before fade starts */
-#define FADE_TIMEOUT 10 /* timeout in ms between each frame of the fade */
#define ICON_SCALE 0.50 /* size of the icon compared to the whole OSD */
#define BG_ALPHA 0.75 /* background transparency */
+#define FG_ALPHA 1.0 /* Alpha value to be used for foreground objects drawn in an OSD window */
#define GSD_OSD_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSD_TYPE_OSD_WINDOW, GsdOsdWindowPrivate))
@@ -371,7 +369,7 @@ static gboolean
hide_timeout (GsdOsdWindow *window)
{
window->priv->hide_timeout_id = 0;
- window->priv->fade_timeout_id = g_timeout_add (FADE_TIMEOUT,
+ window->priv->fade_timeout_id = g_timeout_add (FADE_FRAME_TIMEOUT,
(GSourceFunc) fade_timeout,
window);
@@ -561,10 +559,10 @@ draw_eject (cairo_t *cr,
cairo_rel_line_to (cr, -width / 2, -tri_height);
cairo_rel_line_to (cr, -width / 2, tri_height);
cairo_close_path (cr);
- cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, GSD_OSD_WINDOW_FG_ALPHA);
+ cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, FG_ALPHA);
cairo_fill_preserve (cr);
- cairo_set_source_rgba (cr, 0.6, 0.6, 0.6, GSD_OSD_WINDOW_FG_ALPHA / 2);
+ cairo_set_source_rgba (cr, 0.6, 0.6, 0.6, FG_ALPHA / 2);
cairo_set_line_width (cr, 2);
cairo_stroke (cr);
}
@@ -623,12 +621,12 @@ draw_cross (cairo_t *cr,
cairo_move_to (cr, cx, cy + size/2.0);
cairo_rel_line_to (cr, size, -size);
- cairo_set_source_rgba (cr, 0.6, 0.6, 0.6, GSD_OSD_WINDOW_FG_ALPHA / 2);
+ cairo_set_source_rgba (cr, 0.6, 0.6, 0.6, FG_ALPHA / 2);
cairo_set_line_width (cr, 14);
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
cairo_stroke_preserve (cr);
- cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, GSD_OSD_WINDOW_FG_ALPHA);
+ cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, FG_ALPHA);
cairo_set_line_width (cr, 10);
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
cairo_stroke (cr);
@@ -662,10 +660,10 @@ draw_speaker (cairo_t *cr,
cairo_line_to (cr, _x0, _y0);
cairo_close_path (cr);
- cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, GSD_OSD_WINDOW_FG_ALPHA);
+ cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, FG_ALPHA);
cairo_fill_preserve (cr);
- cairo_set_source_rgba (cr, 0.6, 0.6, 0.6, GSD_OSD_WINDOW_FG_ALPHA / 2);
+ cairo_set_source_rgba (cr, 0.6, 0.6, 0.6, FG_ALPHA / 2);
cairo_set_line_width (cr, 2);
cairo_stroke (cr);
}
@@ -694,7 +692,7 @@ render_speaker (GsdOsdDrawContext *ctx,
}
gdk_cairo_set_source_pixbuf (cr, pixbuf, _x0, _y0);
- cairo_paint_with_alpha (cr, GSD_OSD_WINDOW_FG_ALPHA);
+ cairo_paint_with_alpha (cr, FG_ALPHA);
g_object_unref (pixbuf);
@@ -724,7 +722,7 @@ draw_volume_boxes (GsdOsdDrawContext *ctx,
gtk_style_context_get_background_color (ctx->style, GTK_STATE_NORMAL, &acolor);
gsd_osd_window_color_shade (&acolor, DARKNESS_MULT);
gsd_osd_window_color_reverse (&acolor);
- acolor.alpha = GSD_OSD_WINDOW_FG_ALPHA / 2;
+ acolor.alpha = FG_ALPHA / 2;
gsd_osd_window_draw_rounded_rectangle (cr, 1.0, _x0, _y0, height / 6, width, height);
gdk_cairo_set_source_rgba (cr, &acolor);
cairo_fill (cr);
@@ -733,7 +731,7 @@ draw_volume_boxes (GsdOsdDrawContext *ctx,
if (percentage < 0.01)
return;
gtk_style_context_get_background_color (ctx->style, GTK_STATE_NORMAL, &acolor);
- acolor.alpha = GSD_OSD_WINDOW_FG_ALPHA;
+ acolor.alpha = FG_ALPHA;
gsd_osd_window_draw_rounded_rectangle (cr, 1.0, _x0, _y0, height / 6, x1, height);
gdk_cairo_set_source_rgba (cr, &acolor);
cairo_fill (cr);
@@ -869,7 +867,7 @@ render_custom (GsdOsdDrawContext *ctx,
}
gdk_cairo_set_source_pixbuf (cr, pixbuf, _x0, _y0);
- cairo_paint_with_alpha (cr, GSD_OSD_WINDOW_FG_ALPHA);
+ cairo_paint_with_alpha (cr, FG_ALPHA);
g_object_unref (pixbuf);
diff --git a/src/gsd-osd-window.h b/src/backend/gsd-osd-window.h
similarity index 91%
rename from src/gsd-osd-window.h
rename to src/backend/gsd-osd-window.h
index 2513472..caeb9bc 100644
--- a/src/gsd-osd-window.h
+++ b/src/backend/gsd-osd-window.h
@@ -31,10 +31,6 @@
* semi-transparent, curved popup that appears when you press a hotkey global to
* the desktop, such as to change the volume, switch your monitor's parameters,
* etc.
- *
- * You can create a GsdOsdWindow and use it as a normal GtkWindow. It will
- * automatically center itself, figure out if it needs to be composited, etc.
- * Just pack your widgets in it, sit back, and enjoy the ride.
*/
#ifndef GSD_OSD_WINDOW_H
@@ -45,9 +41,6 @@
G_BEGIN_DECLS
-/* Alpha value to be used for foreground objects drawn in an OSD window */
-#define GSD_OSD_WINDOW_FG_ALPHA 1.0
-
#define GSD_TYPE_OSD_WINDOW (gsd_osd_window_get_type ())
#define GSD_OSD_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSD_TYPE_OSD_WINDOW, GsdOsdWindow))
#define GSD_OSD_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GSD_TYPE_OSD_WINDOW, GsdOsdWindowClass))
diff --git a/src/totem-fullscreen.c b/src/totem-fullscreen.c
index b7a4ce4..fac1b05 100644
--- a/src/totem-fullscreen.c
+++ b/src/totem-fullscreen.c
@@ -37,7 +37,6 @@
#include "totem-time-label.h"
#include "bacon-video-widget.h"
#include "gd-fullscreen-filter.h"
-#include "gsd-osd-window.h"
#define FULLSCREEN_POPUP_TIMEOUT 5
#define FULLSCREEN_MOTION_TIME 200 /* in milliseconds */
@@ -59,7 +58,6 @@ G_MODULE_EXPORT gboolean totem_fullscreen_control_leave_notify (GtkWidget *widge
struct _TotemFullscreenPrivate {
BaconVideoWidget *bvw;
GtkWidget *parent_window;
- GtkWidget *osd;
/* Fullscreen Popups */
GtkWidget *exit_popup;
@@ -348,37 +346,12 @@ totem_fullscreen_show_popups_or_osd (TotemFullscreen *fs,
const char *icon_name,
gboolean show_cursor)
{
- GtkAllocation allocation;
- GdkScreen *screen;
- GdkWindow *window;
- GdkRectangle rect;
- int monitor;
-
if (icon_name == NULL) {
totem_fullscreen_show_popups (fs, show_cursor);
return;
}
- gtk_widget_get_allocation (GTK_WIDGET (fs->priv->bvw), &allocation);
- gtk_window_resize (GTK_WINDOW (fs->priv->osd),
- allocation.height / 8,
- allocation.height / 8);
-
- window = gtk_widget_get_window (GTK_WIDGET (fs->priv->bvw));
- screen = gtk_widget_get_screen (GTK_WIDGET (fs->priv->bvw));
- monitor = gdk_screen_get_monitor_at_window (screen, window);
- gdk_screen_get_monitor_geometry (screen, monitor, &rect);
-
- if (gtk_widget_get_direction (GTK_WIDGET (fs->priv->bvw)) == GTK_TEXT_DIR_RTL)
- gtk_window_move (GTK_WINDOW (fs->priv->osd),
- rect.width - 8 - allocation.height / 8,
- rect.y + 8);
- else
- gtk_window_move (GTK_WINDOW (fs->priv->osd), rect.x + 8, rect.y + 8);
-
- gsd_osd_window_set_action_custom (GSD_OSD_WINDOW (fs->priv->osd),
- icon_name, FALSE);
- gtk_widget_show (fs->priv->osd);
+ bacon_video_widget_popup_osd (fs->priv->bvw, icon_name);
}
G_MODULE_EXPORT gboolean
@@ -410,8 +383,6 @@ totem_fullscreen_set_fullscreen (TotemFullscreen *fs,
bacon_video_widget_set_fullscreen (fs->priv->bvw, fullscreen);
totem_fullscreen_set_cursor (fs, !fullscreen);
- if (fullscreen == FALSE)
- gtk_widget_hide (fs->priv->osd);
fs->priv->is_fullscreen = fullscreen;
@@ -526,7 +497,6 @@ totem_fullscreen_init (TotemFullscreen *self)
G_CALLBACK (totem_fullscreen_exit_popup_draw_cb), self);
self->priv->control_popup = GTK_WIDGET (gtk_builder_get_object (self->priv->xml,
"totem_controls_window"));
- self->priv->osd = gsd_osd_window_new ();
/* Motion notify */
gtk_widget_add_events (self->priv->exit_popup, GDK_POINTER_MOTION_MASK);
@@ -559,11 +529,6 @@ totem_fullscreen_finalize (GObject *object)
fs->priv->filter = NULL;
}
- if (fs->priv->osd != NULL) {
- gtk_widget_destroy (fs->priv->osd);
- fs->priv->osd = NULL;
- }
-
g_signal_handlers_disconnect_by_func (fs->priv->parent_window,
G_CALLBACK (totem_fullscreen_window_realize_cb),
fs);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]