[longomatch/stop: 1/2] Add Property to expand multimediaplayer logo
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [longomatch/stop: 1/2] Add Property to expand multimediaplayer logo
- Date: Sun, 4 Oct 2009 01:40:13 +0000 (UTC)
commit 60746994c5440b42a5899a74329402f1fb1016d3
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Fri Oct 2 17:47:40 2009 +0200
Add Property to expand multimediaplayer logo
CesarPlayer/Gui/PlayerBin.cs | 5 +
CesarPlayer/Player/GstPlayer.cs | 15 ++
CesarPlayer/Player/IPlayer.cs | 5 +
CesarPlayer/gtk-gui/LongoMatch.Gui.PlayerBin.cs | 36 +++---
CesarPlayer/gtk-gui/objects.xml | 1 +
LongoMatch/gtk-gui/LongoMatch.Gui.MainWindow.cs | 1 +
libcesarplayer/src/bacon-video-widget-gst-0.10.c | 158 ++++++++++------------
7 files changed, 118 insertions(+), 103 deletions(-)
---
diff --git a/CesarPlayer/Gui/PlayerBin.cs b/CesarPlayer/Gui/PlayerBin.cs
index 1328818..bd3c1e4 100644
--- a/CesarPlayer/Gui/PlayerBin.cs
+++ b/CesarPlayer/Gui/PlayerBin.cs
@@ -126,6 +126,11 @@ namespace LongoMatch.Gui
set{player.LogoMode = value;}
}
+ public bool ExpandLogo {
+ get{return player.ExpandLogo;}
+ set{player.ExpandLogo = value;}
+ }
+
public Widget VideoWidget{
get{return ((Gtk.EventBox)player);}
}
diff --git a/CesarPlayer/Player/GstPlayer.cs b/CesarPlayer/Player/GstPlayer.cs
index 612591f..6d0d029 100644
--- a/CesarPlayer/Player/GstPlayer.cs
+++ b/CesarPlayer/Player/GstPlayer.cs
@@ -71,6 +71,21 @@ namespace LongoMatch.Video.Player {
bacon_video_widget_set_logo_mode(Handle, value);
}
}
+
+ [GLib.Property ("expand_logo")]
+ public bool ExpandLogo {
+ get {
+ GLib.Value val = GetProperty ("expand_logo");
+ bool ret = (bool) val;
+ val.Dispose ();
+ return ret;
+ }
+ set {
+ GLib.Value val = new GLib.Value(value);
+ SetProperty("expand_logo", val);
+ val.Dispose ();
+ }
+ }
[DllImport("libcesarplayer.dll")]
static extern long bacon_video_widget_get_stream_length(IntPtr raw);
diff --git a/CesarPlayer/Player/IPlayer.cs b/CesarPlayer/Player/IPlayer.cs
index 1ce8a6d..2f1d6d8 100644
--- a/CesarPlayer/Player/IPlayer.cs
+++ b/CesarPlayer/Player/IPlayer.cs
@@ -65,6 +65,11 @@ namespace LongoMatch.Video.Player
set;
}
+ bool ExpandLogo{
+ get;
+ set;
+ }
+
double Volume{
get;
set;
diff --git a/CesarPlayer/gtk-gui/LongoMatch.Gui.PlayerBin.cs b/CesarPlayer/gtk-gui/LongoMatch.Gui.PlayerBin.cs
index 7dd32e8..614fc41 100644
--- a/CesarPlayer/gtk-gui/LongoMatch.Gui.PlayerBin.cs
+++ b/CesarPlayer/gtk-gui/LongoMatch.Gui.PlayerBin.cs
@@ -106,14 +106,14 @@ namespace LongoMatch.Gui {
this.drawbutton.UseUnderline = true;
// Container child drawbutton.Gtk.Container+ContainerChild
Gtk.Alignment w11 = new Gtk.Alignment(0.5F, 0.5F, 0F, 0F);
- // Container child GtkAlignment1.Gtk.Container+ContainerChild
+ // Container child GtkAlignment.Gtk.Container+ContainerChild
Gtk.HBox w12 = new Gtk.HBox();
w12.Spacing = 2;
- // Container child GtkHBox1.Gtk.Container+ContainerChild
+ // Container child GtkHBox.Gtk.Container+ContainerChild
Gtk.Image w13 = new Gtk.Image();
w13.Pixbuf = Stetic.IconLoader.LoadIcon(this, "gtk-select-color", Gtk.IconSize.Menu, 16);
w12.Add(w13);
- // Container child GtkHBox1.Gtk.Container+ContainerChild
+ // Container child GtkHBox.Gtk.Container+ContainerChild
Gtk.Label w15 = new Gtk.Label();
w12.Add(w15);
w11.Add(w12);
@@ -131,14 +131,14 @@ namespace LongoMatch.Gui {
this.playbutton.Relief = ((Gtk.ReliefStyle)(2));
// Container child playbutton.Gtk.Container+ContainerChild
Gtk.Alignment w20 = new Gtk.Alignment(0.5F, 0.5F, 0F, 0F);
- // Container child GtkAlignment2.Gtk.Container+ContainerChild
+ // Container child GtkAlignment.Gtk.Container+ContainerChild
Gtk.HBox w21 = new Gtk.HBox();
w21.Spacing = 2;
- // Container child GtkHBox2.Gtk.Container+ContainerChild
+ // Container child GtkHBox.Gtk.Container+ContainerChild
Gtk.Image w22 = new Gtk.Image();
w22.Pixbuf = Stetic.IconLoader.LoadIcon(this, "gtk-media-play", Gtk.IconSize.Button, 20);
w21.Add(w22);
- // Container child GtkHBox2.Gtk.Container+ContainerChild
+ // Container child GtkHBox.Gtk.Container+ContainerChild
Gtk.Label w24 = new Gtk.Label();
w21.Add(w24);
w20.Add(w21);
@@ -156,14 +156,14 @@ namespace LongoMatch.Gui {
this.pausebutton.Relief = ((Gtk.ReliefStyle)(2));
// Container child pausebutton.Gtk.Container+ContainerChild
Gtk.Alignment w29 = new Gtk.Alignment(0.5F, 0.5F, 0F, 0F);
- // Container child GtkAlignment3.Gtk.Container+ContainerChild
+ // Container child GtkAlignment.Gtk.Container+ContainerChild
Gtk.HBox w30 = new Gtk.HBox();
w30.Spacing = 2;
- // Container child GtkHBox3.Gtk.Container+ContainerChild
+ // Container child GtkHBox.Gtk.Container+ContainerChild
Gtk.Image w31 = new Gtk.Image();
w31.Pixbuf = Stetic.IconLoader.LoadIcon(this, "gtk-media-pause", Gtk.IconSize.Button, 20);
w30.Add(w31);
- // Container child GtkHBox3.Gtk.Container+ContainerChild
+ // Container child GtkHBox.Gtk.Container+ContainerChild
Gtk.Label w33 = new Gtk.Label();
w30.Add(w33);
w29.Add(w30);
@@ -181,14 +181,14 @@ namespace LongoMatch.Gui {
this.prevbutton.Relief = ((Gtk.ReliefStyle)(2));
// Container child prevbutton.Gtk.Container+ContainerChild
Gtk.Alignment w38 = new Gtk.Alignment(0.5F, 0.5F, 0F, 0F);
- // Container child GtkAlignment4.Gtk.Container+ContainerChild
+ // Container child GtkAlignment.Gtk.Container+ContainerChild
Gtk.HBox w39 = new Gtk.HBox();
w39.Spacing = 2;
- // Container child GtkHBox4.Gtk.Container+ContainerChild
+ // Container child GtkHBox.Gtk.Container+ContainerChild
Gtk.Image w40 = new Gtk.Image();
w40.Pixbuf = Stetic.IconLoader.LoadIcon(this, "gtk-media-previous", Gtk.IconSize.Button, 20);
w39.Add(w40);
- // Container child GtkHBox4.Gtk.Container+ContainerChild
+ // Container child GtkHBox.Gtk.Container+ContainerChild
Gtk.Label w42 = new Gtk.Label();
w39.Add(w42);
w38.Add(w39);
@@ -207,14 +207,14 @@ namespace LongoMatch.Gui {
this.nextbutton.Relief = ((Gtk.ReliefStyle)(2));
// Container child nextbutton.Gtk.Container+ContainerChild
Gtk.Alignment w47 = new Gtk.Alignment(0.5F, 0.5F, 0F, 0F);
- // Container child GtkAlignment5.Gtk.Container+ContainerChild
+ // Container child GtkAlignment.Gtk.Container+ContainerChild
Gtk.HBox w48 = new Gtk.HBox();
w48.Spacing = 2;
- // Container child GtkHBox5.Gtk.Container+ContainerChild
+ // Container child GtkHBox.Gtk.Container+ContainerChild
Gtk.Image w49 = new Gtk.Image();
w49.Pixbuf = Stetic.IconLoader.LoadIcon(this, "gtk-media-next", Gtk.IconSize.Button, 20);
w48.Add(w49);
- // Container child GtkHBox5.Gtk.Container+ContainerChild
+ // Container child GtkHBox.Gtk.Container+ContainerChild
Gtk.Label w51 = new Gtk.Label();
w48.Add(w51);
w47.Add(w48);
@@ -267,14 +267,14 @@ namespace LongoMatch.Gui {
this.volumebutton.Relief = ((Gtk.ReliefStyle)(2));
// Container child volumebutton.Gtk.Container+ContainerChild
Gtk.Alignment w60 = new Gtk.Alignment(0.5F, 0.5F, 0F, 0F);
- // Container child GtkAlignment6.Gtk.Container+ContainerChild
+ // Container child GtkAlignment.Gtk.Container+ContainerChild
Gtk.HBox w61 = new Gtk.HBox();
w61.Spacing = 2;
- // Container child GtkHBox6.Gtk.Container+ContainerChild
+ // Container child GtkHBox.Gtk.Container+ContainerChild
Gtk.Image w62 = new Gtk.Image();
w62.Pixbuf = Stetic.IconLoader.LoadIcon(this, "stock_volume", Gtk.IconSize.Button, 20);
w61.Add(w62);
- // Container child GtkHBox6.Gtk.Container+ContainerChild
+ // Container child GtkHBox.Gtk.Container+ContainerChild
Gtk.Label w64 = new Gtk.Label();
w61.Add(w64);
w60.Add(w61);
diff --git a/CesarPlayer/gtk-gui/objects.xml b/CesarPlayer/gtk-gui/objects.xml
index 90b3bef..c75d338 100644
--- a/CesarPlayer/gtk-gui/objects.xml
+++ b/CesarPlayer/gtk-gui/objects.xml
@@ -8,6 +8,7 @@
<itemgroup label="PlayerBin Properties">
<property name="Rate" />
<property name="LogoMode" />
+ <property name="ExpandLogo" />
</itemgroup>
</itemgroups>
<signals>
diff --git a/LongoMatch/gtk-gui/LongoMatch.Gui.MainWindow.cs b/LongoMatch/gtk-gui/LongoMatch.Gui.MainWindow.cs
index 9291a6d..f6ea97a 100644
--- a/LongoMatch/gtk-gui/LongoMatch.Gui.MainWindow.cs
+++ b/LongoMatch/gtk-gui/LongoMatch.Gui.MainWindow.cs
@@ -296,6 +296,7 @@ namespace LongoMatch.Gui {
this.playerbin1.Name = "playerbin1";
this.playerbin1.Rate = 0F;
this.playerbin1.LogoMode = false;
+ this.playerbin1.ExpandLogo = false;
this.hbox1.Add(this.playerbin1);
Gtk.Box.BoxChild w10 = ((Gtk.Box.BoxChild)(this.hbox1[this.playerbin1]));
w10.Position = 1;
diff --git a/libcesarplayer/src/bacon-video-widget-gst-0.10.c b/libcesarplayer/src/bacon-video-widget-gst-0.10.c
index 11a7ae6..1cd1158 100644
--- a/libcesarplayer/src/bacon-video-widget-gst-0.10.c
+++ b/libcesarplayer/src/bacon-video-widget-gst-0.10.c
@@ -110,6 +110,7 @@ enum
{
PROP_0,
PROP_LOGO_MODE,
+ PROP_EXPAND_LOGO,
PROP_POSITION,
PROP_CURRENT_TIME,
PROP_STREAM_LENGTH,
@@ -170,6 +171,7 @@ struct BaconVideoWidgetPrivate
/* Other stuff */
gboolean logo_mode;
+ gboolean expand_logo;
gboolean cursor_shown;
gboolean fullscreen_mode;
gboolean auto_resize;
@@ -675,102 +677,78 @@ bacon_video_widget_expose_event (GtkWidget *widget, GdkEventExpose *event)
guchar *pixels;
int rowstride;
gint width, height, alloc_width, alloc_height, logo_x, logo_y;
- gfloat width_ratio, height_ratio;
-
- frame = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
- FALSE, 8, widget->allocation.width, widget->allocation.height);
+ gfloat ratio;
+ /* Checking if allocated space is smaller than our logo */
+
+
width = gdk_pixbuf_get_width (bvw->priv->logo_pixbuf);
height = gdk_pixbuf_get_height (bvw->priv->logo_pixbuf);
alloc_width = widget->allocation.width;
alloc_height = widget->allocation.height;
- /* Checking if allocated space is smaller than our logo */
-
- if ((alloc_width < width) || (alloc_height < height)) {
- width_ratio = (gfloat) alloc_width / (gfloat) width;
- height_ratio = (gfloat) alloc_height / (gfloat) height;
- width_ratio = MIN (width_ratio, height_ratio);
- height_ratio = width_ratio;
- } else
- width_ratio = height_ratio = 1.0;
-
- logo_x = (alloc_width / 2) - (width * width_ratio / 2);
- logo_y = (alloc_height / 2) - (height * height_ratio / 2);
-
- /* Scaling to available space */
-
- gdk_pixbuf_composite (bvw->priv->logo_pixbuf,
- frame,
- 0, 0,
- alloc_width, alloc_height,
- logo_x, logo_y, width_ratio, height_ratio, GDK_INTERP_BILINEAR, 255);
-
- /* Drawing our frame */
-
- rowstride = gdk_pixbuf_get_rowstride (frame);
-
- pixels = gdk_pixbuf_get_pixels (frame) +
- rowstride * event->area.y + event->area.x * 3;
-
- gdk_draw_rgb_image_dithalign (widget->window,
- widget->style->black_gc,
- event->area.x, event->area.y,
- event->area.width, event->area.height,
- GDK_RGB_DITHER_NORMAL, pixels,
- rowstride, event->area.x, event->area.y);
-
- g_object_unref (frame);
- /* draw logo here */
- /*GdkPixbuf *logo = NULL;
- gint s_width, s_height, w_width, w_height;
- gfloat ratio;
- GdkRegion *region;
- GdkRectangle rect;
-
- rect.x = rect.y = 0;
- rect.width = widget->allocation.width;
- rect.height = widget->allocation.height;
- region = gdk_region_rectangle (&rect);
-
- gdk_window_begin_paint_region (win, region);
- gdk_region_destroy (region);
-
- gdk_window_clear_area (win,
- 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;
+ if ((gfloat) alloc_width / width > (gfloat) alloc_height / height) {
+ ratio = (gfloat) alloc_height / height;
} else {
- ratio = (gfloat) w_width / s_width;
+ ratio = (gfloat) alloc_width / width;
}
- s_width *= ratio;
- s_height *= ratio;
-
- if (s_width <= 1 || s_height <= 1) {
- if (xoverlay != NULL)
- gst_object_unref (xoverlay);
- gdk_window_end_paint (win);
- return TRUE;
- }
+ width *= ratio;
+ height *= ratio;
- logo = gdk_pixbuf_scale_simple (bvw->priv->logo_pixbuf,
- s_width, s_height, GDK_INTERP_BILINEAR);
+ logo_x = (alloc_width / 2) - (width / 2);
+ logo_y = (alloc_height / 2) - (height/ 2);
- 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,
- s_width, s_height, GDK_RGB_DITHER_NONE, 0, 0);
- gdk_window_end_paint (win);
- g_object_unref (logo);*/
+ /* Drawing our frame */
+
+ if (bvw->priv->expand_logo){
+ /* Scaling to available space */
+
+ frame = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
+ FALSE, 8, widget->allocation.width, widget->allocation.height);
+
+ gdk_pixbuf_composite (bvw->priv->logo_pixbuf,
+ frame,
+ 0, 0,
+ alloc_width, alloc_height,
+ logo_x, logo_y, ratio,ratio, GDK_INTERP_BILINEAR, 255);
+
+ rowstride = gdk_pixbuf_get_rowstride (frame);
+
+ pixels = gdk_pixbuf_get_pixels (frame) +
+ rowstride * event->area.y + event->area.x * 3;
+
+ gdk_draw_rgb_image_dithalign (widget->window,
+ widget->style->black_gc,
+ event->area.x, event->area.y,
+ event->area.width, event->area.height,
+ GDK_RGB_DITHER_NORMAL, pixels,
+ rowstride, event->area.x, event->area.y);
+
+ g_object_unref (frame);
+ }else{
+ gdk_window_clear_area (win,
+ 0, 0,
+ widget->allocation.width,
+ widget->allocation.height);
+
+ if (width <= 1 || height <= 1) {
+ if (xoverlay != NULL)
+ gst_object_unref (xoverlay);
+ gdk_window_end_paint (win);
+ return TRUE;
+ }
+
+ frame = gdk_pixbuf_scale_simple (bvw->priv->logo_pixbuf,
+ width, height, GDK_INTERP_BILINEAR);
+
+ gdk_draw_pixbuf (win, gtk_widget_get_style (widget)->fg_gc[0], frame,
+ 0, 0, logo_x, logo_y,
+ width, height, GDK_RGB_DITHER_NONE, 0, 0);
+
+ g_object_unref (frame);
+ }
} else if (win) {
/* No pixbuf, just draw a black background then */
gdk_window_clear_area (win,
@@ -1007,6 +985,10 @@ bacon_video_widget_class_init (BaconVideoWidgetClass * klass)
g_param_spec_boolean ("logo_mode", NULL,
NULL, FALSE,
G_PARAM_READWRITE));
+ g_object_class_install_property (object_class, PROP_EXPAND_LOGO,
+ g_param_spec_boolean ("expand_logo", NULL,
+ NULL, TRUE,
+ G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_POSITION,
g_param_spec_int ("position", NULL, NULL,
0, G_MAXINT, 0,
@@ -1165,7 +1147,7 @@ bacon_video_widget_init (BaconVideoWidget * bvw)
priv->audiotags = NULL;
priv->videotags = NULL;
priv->zoom = 1.0;
-
+ priv->expand_logo=TRUE;
priv->lock = g_mutex_new ();
bvw->priv->missing_plugins = NULL;
@@ -1996,6 +1978,9 @@ bacon_video_widget_set_property (GObject * object, guint property_id,
bacon_video_widget_set_logo_mode (bvw,
g_value_get_boolean (value));
break;
+ case PROP_EXPAND_LOGO:
+ bvw->priv->expand_logo=g_value_get_boolean (value);
+ break;
case PROP_SHOW_CURSOR:
bacon_video_widget_set_show_cursor (bvw,
g_value_get_boolean (value));
@@ -2023,6 +2008,9 @@ bacon_video_widget_get_property (GObject * object, guint property_id,
g_value_set_boolean (value,
bacon_video_widget_get_logo_mode (bvw));
break;
+ case PROP_EXPAND_LOGO:
+ g_value_set_boolean (value,bvw->priv->expand_logo);
+ break;
case PROP_POSITION:
g_value_set_int64 (value, bacon_video_widget_get_position (bvw));
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]