#! /bin/sh /usr/share/dpatch/dpatch-run ## 09_fix_bacon-video-widgets_stolen_from_1_4_3.dpatch by Gert Michael Kulyk ## All lines beginning with `## DP:' are a description of the patch. ## DP: Should fix some crashes, mainly related to launchpad bug #35229, but also fixes some 64bit issues. @DPATCH@ diff -urNad totem-1.4.1.orig/src/backend/bacon-video-widget-gst-0.10.c totem-1.4.1/src/backend/bacon-video-widget-gst-0.10.c --- totem-1.4.1.orig/src/backend/bacon-video-widget-gst-0.10.c 2006-07-31 23:47:18.000000000 +0200 +++ totem-1.4.1/src/backend/bacon-video-widget-gst-0.10.c 2006-07-31 23:43:25.000000000 +0200 @@ -2575,6 +2575,10 @@ g_return_if_fail (bvw != NULL); g_return_if_fail (BACON_IS_VIDEO_WIDGET (bvw)); + /* HACK! */ + if (bvw->priv->logo_pixbuf != NULL) + return; + bvw->priv->logo_pixbuf = gdk_pixbuf_new_from_file (filename, &error); if (error) { @@ -3921,10 +3925,10 @@ if (!strcmp (entry->key, "/apps/totem/network-buffer-threshold")) { g_object_set (bvw->priv->play, "queue-threshold", - (guint64) GST_SECOND * gconf_value_get_float (entry->value), NULL); + (guint64) (GST_SECOND * gconf_value_get_float (entry->value)), NULL); } else if (!strcmp (entry->key, "/apps/totem/buffer-size")) { g_object_set (bvw->priv->play, "queue-threshold", - (guint64) GST_SECOND * gconf_value_get_float (entry->value), NULL); + (guint64) (GST_SECOND * gconf_value_get_float (entry->value)), NULL); } } @@ -4425,14 +4429,14 @@ GCONF_PREFIX "/buffer-size", NULL); if (confvalue != NULL) { g_object_set (bvw->priv->play, "queue-size", - (guint64) GST_SECOND * gconf_value_get_float (confvalue), NULL); + (guint64) (GST_SECOND * gconf_value_get_float (confvalue)), NULL); gconf_value_free (confvalue); } confvalue = gconf_client_get_without_default (bvw->priv->gc, GCONF_PREFIX "/network-buffer-threshold", NULL); if (confvalue != NULL) { g_object_set (bvw->priv->play, "queue-threshold", - (guint64) GST_SECOND * gconf_value_get_float (confvalue), NULL); + (guint64) (GST_SECOND * gconf_value_get_float (confvalue)), NULL); gconf_value_free (confvalue); } diff -urNad totem-1.4.1.orig/src/backend/bacon-video-widget-gst.c totem-1.4.1/src/backend/bacon-video-widget-gst.c --- totem-1.4.1.orig/src/backend/bacon-video-widget-gst.c 2006-05-14 12:41:06.000000000 +0200 +++ totem-1.4.1/src/backend/bacon-video-widget-gst.c 2006-07-31 23:43:25.000000000 +0200 @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - * $Id: bacon-video-widget-gst.c,v 1.206.2.1 2006/05/14 10:41:06 hadess Exp $ + * $Id: bacon-video-widget-gst.c,v 1.206.2.3 2006/07/04 09:17:17 hadess Exp $ * * * The Totem project hereby grant permission for non-gpl compatible GStreamer @@ -2169,6 +2169,10 @@ g_return_if_fail (bvw != NULL); g_return_if_fail (BACON_IS_VIDEO_WIDGET (bvw)); + /* HACK! */ + if (bvw->priv->logo_pixbuf != NULL) + return; + bvw->priv->logo_pixbuf = gdk_pixbuf_new_from_file (filename, &error); if (error) { @@ -3307,10 +3311,10 @@ if (!strcmp (entry->key, "/apps/totem/network-buffer-threshold")) { g_object_set (G_OBJECT (bvw->priv->play), "queue-threshold", - (guint64) GST_SECOND * gconf_value_get_float (entry->value), NULL); + (guint64) (GST_SECOND * gconf_value_get_float (entry->value)), NULL); } else if (!strcmp (entry->key, "/apps/totem/buffer-size")) { g_object_set (G_OBJECT (bvw->priv->play), "queue-threshold", - (guint64) GST_SECOND * gconf_value_get_float (entry->value), NULL); + (guint64) (GST_SECOND * gconf_value_get_float (entry->value)), NULL); } } @@ -3699,14 +3703,14 @@ GCONF_PREFIX"/buffer-size", NULL); if (confvalue != NULL) { g_object_set (G_OBJECT (bvw->priv->play), "queue-size", - (guint64) GST_SECOND * gconf_value_get_float (confvalue), NULL); + (guint64) (GST_SECOND * gconf_value_get_float (confvalue)), NULL); gconf_value_free (confvalue); } confvalue = gconf_client_get_without_default (bvw->priv->gc, GCONF_PREFIX"/network-buffer-threshold", NULL); if (confvalue != NULL) { g_object_set (G_OBJECT (bvw->priv->play), "queue-threshold", - (guint64) GST_SECOND * gconf_value_get_float (confvalue), NULL); + (guint64) (GST_SECOND * gconf_value_get_float (confvalue)), NULL); gconf_value_free (confvalue); } diff -urNad totem-1.4.1.orig/src/backend/bacon-video-widget-xine.c totem-1.4.1/src/backend/bacon-video-widget-xine.c --- totem-1.4.1.orig/src/backend/bacon-video-widget-xine.c 2006-04-18 23:04:16.000000000 +0200 +++ totem-1.4.1/src/backend/bacon-video-widget-xine.c 2006-07-31 23:43:25.000000000 +0200 @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - * $Id: bacon-video-widget-xine.c,v 1.228 2006/04/18 21:04:16 hadess Exp $ + * $Id: bacon-video-widget-xine.c,v 1.228.2.2 2006/07/06 18:50:53 hadess Exp $ * * the xine engine in a widget - implementation */ @@ -157,10 +157,13 @@ float seek_dest; gint64 seek_dest_time; + /* Logo */ + gboolean logo_mode; + GdkPixbuf *logo_pixbuf; + /* Other stuff */ int xpos, ypos; gboolean can_dvd, can_vcd, can_cdda; - gboolean logo_mode; guint tick_id; gboolean have_xvidmode; gboolean auto_resize; @@ -1113,6 +1116,8 @@ bvw->priv->video_window = widget->window; + widget->style = gtk_style_attach (widget->style, widget->window); + /* Set a black background */ gdk_draw_rectangle (widget->window, widget->style->black_gc, TRUE, attr.x, attr.y, @@ -1761,18 +1766,58 @@ bacon_video_widget_expose (GtkWidget *widget, GdkEventExpose *event) { BaconVideoWidget *bvw = (BaconVideoWidget *) widget; - XExposeEvent *expose; + gboolean draw_logo, has_video; - if (event->count != 0) - return FALSE; + /* if there's only audio and no visualisation, draw the logo as well */ + has_video = xine_get_stream_info(bvw->priv->stream, + XINE_STREAM_INFO_HAS_VIDEO); + draw_logo = !has_video && !bvw->priv->show_vfx; - expose = g_new0 (XExposeEvent, 1); - expose->count = event->count; + if (bvw->priv->logo_mode == FALSE) { + XExposeEvent *expose; - xine_port_send_gui_data (bvw->priv->vo_driver, - XINE_GUI_SEND_EXPOSE_EVENT, expose); + if (event->count != 0) + return FALSE; - g_free (expose); + expose = g_new0 (XExposeEvent, 1); + expose->count = event->count; + + xine_port_send_gui_data (bvw->priv->vo_driver, + XINE_GUI_SEND_EXPOSE_EVENT, expose); + + g_free (expose); + } else { + int s_width, s_height, w_width, w_height; + GdkPixbuf *logo = NULL; + gfloat ratio; + + /* Start with a nice black canvas */ + gdk_draw_rectangle (widget->window, widget->style->black_gc, TRUE, 0, 0, + widget->allocation.width, widget->allocation.height); + + s_width = gdk_pixbuf_get_width (bvw->priv->logo_pixbuf); + s_height = gdk_pixbuf_get_height (bvw->priv->logo_pixbuf); + w_width = widget->allocation.width; + w_height = widget->allocation.height; + + if ((gfloat) w_width / s_width > (gfloat) w_height / s_height) { + ratio = (gfloat) w_height / s_height; + } else { + ratio = (gfloat) w_width / s_width; + } + + s_width *= ratio; + s_height *= ratio; + + logo = gdk_pixbuf_scale_simple (bvw->priv->logo_pixbuf, + s_width, s_height, GDK_INTERP_BILINEAR); + + gdk_draw_pixbuf (widget->window, widget->style->fg_gc[0], logo, + 0, 0, (w_width - s_width) / 2, (w_height - s_height) / 2, + s_width, s_height, GDK_RGB_DITHER_NONE, 0, 0); + + gdk_pixbuf_unref (logo); + } return FALSE; } @@ -2417,18 +2462,29 @@ g_return_if_fail (bvw->priv->xine != NULL); bvw->priv->logo_mode = logo_mode; + + if (logo_mode == FALSE) { + gdk_pixbuf_unref (bvw->priv->logo_pixbuf); + bvw->priv->logo_pixbuf = NULL; + } } void bacon_video_widget_set_logo (BaconVideoWidget *bvw, char *filename) { + GError *err = NULL; + g_return_if_fail (bvw != NULL); g_return_if_fail (BACON_IS_VIDEO_WIDGET(bvw)); g_return_if_fail (bvw->priv->xine != NULL); g_return_if_fail (filename != NULL); + g_return_if_fail (bvw->priv->logo_pixbuf == NULL); - if (bacon_video_widget_open (bvw, filename, NULL) != FALSE) { - bacon_video_widget_play (bvw, NULL); + bvw->priv->logo_pixbuf = gdk_pixbuf_new_from_file (filename, &err); + if (err) { + g_warning ("Couldn't open logo image: %s", + err->message ? err->message : "No reason"); + g_error_free (err); } }