[totem] Bug 480200 – Show Totem new logo as default screen



commit 32f456f8f4a4fd287673a974c58cfe2f0557d24b
Author: Philip Withnall <philip tecnocode co uk>
Date:   Sat Aug 8 20:58:18 2009 +0100

    Bug 480200 â?? Show Totem new logo as default screen
    
    Use the new Totem logo in both the browser plugin and main player, and
    simplify logo handling in BVW. Closes: bgo#480200

 browser-plugin/totem-plugin-viewer.c      |   54 +----------------------------
 data/Makefile.am                          |    1 -
 data/totem_logo.png                       |  Bin 185953 -> 0 bytes
 src/Makefile.am                           |    1 -
 src/backend/bacon-video-widget-gst-0.10.c |   44 +++++++----------------
 src/totem.c                               |    2 +-
 6 files changed, 16 insertions(+), 86 deletions(-)
---
diff --git a/browser-plugin/totem-plugin-viewer.c b/browser-plugin/totem-plugin-viewer.c
index f1809f5..f48f7f6 100644
--- a/browser-plugin/totem-plugin-viewer.c
+++ b/browser-plugin/totem-plugin-viewer.c
@@ -375,68 +375,16 @@ totem_embedded_set_state (TotemEmbedded *emb, TotemStates state)
 	emb->state = state;
 }
 
-static GdkPixbuf *
-totem_embedded_pad_pixbuf_for_size (GdkPixbuf *pixbuf,
-				    int width, int height)
-{
-	GdkPixbuf *logo;
-	guchar *pixels;
-	int rowstride, i;
-	int dest_x, dest_y;
-
-	logo = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
-			       TRUE, 8, width, height);
-	pixels = gdk_pixbuf_get_pixels (logo);
-	rowstride = gdk_pixbuf_get_rowstride (logo);
-
-	/* Clear it */
-	for (i = 0; i < height; i++) {
-		memset (pixels + i * rowstride, 0, width * 4);
-	}
-
-	dest_x = (width - gdk_pixbuf_get_width (pixbuf)) / 2;
-	dest_y = (height - gdk_pixbuf_get_height (pixbuf)) / 2;
-	gdk_pixbuf_copy_area (pixbuf,
-			      0, 0,
-			      MIN (gdk_pixbuf_get_width (logo), gdk_pixbuf_get_width (pixbuf)),
-			      MIN (gdk_pixbuf_get_height (logo), gdk_pixbuf_get_height (pixbuf)),
-			      logo,
-			      dest_x,
-			      dest_y);
-
-	return logo;
-}
-
 static void
 totem_embedded_set_logo_by_name (TotemEmbedded *embedded,
 				 const char *name)
 {
-	GtkIconTheme *theme;
-	GdkPixbuf *logo, *padded;
-	int size, width, height;
-
 	totem_embedded_set_state (embedded, TOTEM_STATE_STOPPED);
 
 	if (embedded->audioonly != FALSE || embedded->hidden != FALSE)
 		return;
 
-	theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (embedded->window));
-
-	width = GTK_WIDGET (embedded->bvw)->allocation.width;
-	height = GTK_WIDGET (embedded->bvw)->allocation.height;
-	size = MIN (width, height);
-
-	logo = gtk_icon_theme_load_icon (theme, name, size, 0, NULL);
-	if (logo == NULL) {
-		g_warning ("Couldn't load '%s' icon from theme", name);
-		return;
-	}
-	padded = totem_embedded_pad_pixbuf_for_size (logo, width, height);
-	g_object_unref (logo);
-	if (padded != NULL) {
-		bacon_video_widget_set_logo_pixbuf (embedded->bvw, padded);
-		bacon_video_widget_set_logo_mode (embedded->bvw, TRUE);
-	}
+	bacon_video_widget_set_logo (embedded->bvw, name);
 }
 
 static void
diff --git a/data/Makefile.am b/data/Makefile.am
index 40dea67..58b3f73 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -10,7 +10,6 @@ stuff_DATA =				\
 	filmholes.png			\
 	filmholes-big-left.png		\
 	filmholes-big-right.png		\
-	totem_logo.png			\
 	totem.ui			\
 	fullscreen.ui			\
 	playlist.ui			\
diff --git a/src/Makefile.am b/src/Makefile.am
index 7dd34c9..a797b25 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -14,7 +14,6 @@ common_defines = \
 	-DDATADIR=\""$(datadir)"\"			\
 	-DLIBEXECDIR=\""$(libexecdir)"\"		\
 	-DBINDIR=\""$(bindir)"\"			\
-	-DLOGO_PATH=DATADIR\"\"G_DIR_SEPARATOR_S\"totem\"G_DIR_SEPARATOR_S\"totem_logo.png\"	\
 	$(DISABLE_DEPRECATED)
 
 modules_flags = -export_dynamic -avoid-version -module -no-undefined
diff --git a/src/backend/bacon-video-widget-gst-0.10.c b/src/backend/bacon-video-widget-gst-0.10.c
index 642b269..58d12d3 100644
--- a/src/backend/bacon-video-widget-gst-0.10.c
+++ b/src/backend/bacon-video-widget-gst-0.10.c
@@ -86,6 +86,8 @@
 #define DEFAULT_WIDTH  315
 #define SMALL_STREAM_WIDTH 200
 #define SMALL_STREAM_HEIGHT 120
+/* Maximum size of the logo */
+#define LOGO_SIZE 256
 
 #define is_error(e, d, c) \
   (e->domain == GST_##d##_ERROR && \
@@ -717,6 +719,10 @@ bacon_video_widget_expose_event (GtkWidget *widget, GdkEventExpose *event)
       w_width = widget->allocation.width;
       w_height = widget->allocation.height;
 
+      /* Limit the width/height to 256Ã?256 pixels, but only if we're displaying the logo proper */
+      if (!bvw->priv->cover_pixbuf && (w_width > LOGO_SIZE || w_height > LOGO_SIZE))
+        w_width = w_height = LOGO_SIZE;
+
       if ((gfloat) w_width / s_width > (gfloat) w_height / s_height) {
         ratio = (gfloat) w_height / s_height;
       } else {
@@ -737,7 +743,7 @@ bacon_video_widget_expose_event (GtkWidget *widget, GdkEventExpose *event)
           s_width, s_height, GDK_INTERP_BILINEAR);
 
       gdk_draw_pixbuf (win, gtk_widget_get_style (widget)->fg_gc[0], logo,
-          0, 0, (w_width - s_width) / 2, (w_height - s_height) / 2,
+          0, 0, (widget->allocation.width - s_width) / 2, (widget->allocation.height - s_height) / 2,
           s_width, s_height, GDK_RGB_DITHER_NONE, 0, 0);
 
       gdk_window_end_paint (win);
@@ -3649,54 +3655,32 @@ bacon_video_widget_dvd_event (BaconVideoWidget * bvw,
 /**
  * bacon_video_widget_set_logo:
  * @bvw: a #BaconVideoWidget
- * @filename: the logo filename
+ * @name: the icon name of the logo
  *
  * Sets the logo displayed on the video widget when no stream is loaded.
  **/
 void
-bacon_video_widget_set_logo (BaconVideoWidget * bvw, const gchar * filename)
+bacon_video_widget_set_logo (BaconVideoWidget *bvw, const gchar *name)
 {
+  GtkIconTheme *theme;
   GError *error = NULL;
 
   g_return_if_fail (BACON_IS_VIDEO_WIDGET (bvw));
-  g_return_if_fail (filename != NULL);
+  g_return_if_fail (name != NULL);
 
   if (bvw->priv->logo_pixbuf != NULL)
     g_object_unref (bvw->priv->logo_pixbuf);
 
-  bvw->priv->logo_pixbuf = gdk_pixbuf_new_from_file (filename, &error);
+  theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (bvw)));
+  bvw->priv->logo_pixbuf = gtk_icon_theme_load_icon (theme, name, LOGO_SIZE, 0, &error);
 
   if (error) {
-    g_warning ("An error occurred trying to open logo %s: %s",
-               filename, error->message);
+    g_warning ("An error occurred trying to open logo %s: %s", name, error->message);
     g_error_free (error);
   }
 }
 
 /**
- * bacon_video_widget_set_logo_pixbuf:
- * @bvw: a #BaconVideoWidget
- * @logo: the logo #GdkPixbuf
- *
- * Sets the logo displayed on the video widget when no stream is loaded,
- * by passing in a #GdkPixbuf directly. @logo is reffed, so can be unreffed
- * once this function call is complete.
- **/
-void
-bacon_video_widget_set_logo_pixbuf (BaconVideoWidget * bvw, GdkPixbuf *logo)
-{
-  g_return_if_fail (bvw != NULL);
-  g_return_if_fail (BACON_IS_VIDEO_WIDGET (bvw));
-  g_return_if_fail (logo != NULL);
-
-  if (bvw->priv->logo_pixbuf != NULL)
-    g_object_unref (bvw->priv->logo_pixbuf);
-
-  g_object_ref (logo);
-  bvw->priv->logo_pixbuf = logo;
-}
-
-/**
  * bacon_video_widget_set_logo_mode:
  * @bvw: a #BaconVideoWidget
  * @logo_mode: %TRUE to display the logo, %FALSE otherwise
diff --git a/src/totem.c b/src/totem.c
index 3ad51e0..61b2c18 100644
--- a/src/totem.c
+++ b/src/totem.c
@@ -265,7 +265,7 @@ main (int argc, char **argv)
 	}
 
 	/* Set the logo at the last minute so we won't try to show it before a video */
-	bacon_video_widget_set_logo (totem->bvw, LOGO_PATH);
+	bacon_video_widget_set_logo (totem->bvw, "totem");
 
 	if (optionstate.fullscreen == FALSE)
 		gdk_window_set_cursor (totem->win->window, NULL);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]