[longomatch/fakelive] Add Logo property to the capturer bin
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch/fakelive] Add Logo property to the capturer bin
- Date: Mon, 15 Mar 2010 21:45:46 +0000 (UTC)
commit c57264a73a29594ab9dc334dbb41b54df46fc1e7
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Sat Mar 13 13:51:26 2010 +0100
Add Logo property to the capturer bin
CesarPlayer/Gui/CapturerBin.cs | 61 +++++++++-
CesarPlayer/gtk-gui/LongoMatch.Gui.CapturerBin.cs | 139 +++++++++++----------
CesarPlayer/gtk-gui/gui.stetic | 27 +++-
3 files changed, 152 insertions(+), 75 deletions(-)
---
diff --git a/CesarPlayer/Gui/CapturerBin.cs b/CesarPlayer/Gui/CapturerBin.cs
index 6717e4c..944ec77 100644
--- a/CesarPlayer/Gui/CapturerBin.cs
+++ b/CesarPlayer/Gui/CapturerBin.cs
@@ -20,6 +20,8 @@
using System;
using Gtk;
+using Gdk;
+using GLib;
using LongoMatch.Video;
using LongoMatch.Video.Capturer;
using LongoMatch.Video.Utils;
@@ -35,13 +37,15 @@ namespace LongoMatch.Gui
{
public event EventHandler CaptureFinished;
+ private Pixbuf logopix;
+
ICapturer capturer;
public CapturerBin()
{
this.Build();
- Type = CapturerType.FAKE;
- }
+ Type = CapturerType.FAKE;
+ }
public CapturerType Type {
set{
@@ -56,6 +60,17 @@ namespace LongoMatch.Gui
((Widget)capturer).Show();
}
}
+
+ public string Logo{
+ set{
+ try{
+ this.logopix = new Pixbuf(value);
+ Console.WriteLine("Setting logo");
+ }catch{
+ // Ignore errors if the file doesn't exists
+ }
+ }
+ }
public string OutputFile {
set{
@@ -117,7 +132,7 @@ namespace LongoMatch.Gui
protected virtual void OnStopbuttonClicked (object sender, System.EventArgs e)
{
- MessageDialog md = new MessageDialog((Window)this.Toplevel, DialogFlags.Modal, MessageType.Question, ButtonsType.YesNo,
+ MessageDialog md = new MessageDialog((Gtk.Window)this.Toplevel, DialogFlags.Modal, MessageType.Question, ButtonsType.YesNo,
Catalog.GetString("You are going to stop and finish the current capture."+"\n"+
"Do you want to proceed?"));
if (md.Run() == (int)ResponseType.Yes){
@@ -134,5 +149,45 @@ namespace LongoMatch.Gui
protected virtual void OnTick (int ellapsedTime){
timelabel.Text = "Time: " + TimeString.MSecondsToSecondsString(CurrentTime);
}
+
+ protected virtual void OnLogodrawingareaExposeEvent (object o, Gtk.ExposeEventArgs args)
+ {
+ Gdk.Window win;
+ Rectangle area;
+ Pixbuf frame;
+ Pixbuf drawing;
+ int width, height, allocWidth, allocHeight, logoX, logoY;
+ float ratio;
+
+ if (logopix == null)
+ return;
+
+ win = logodrawingarea.GdkWindow;
+ width = logopix.Width;
+ height = logopix.Height;
+ allocWidth = logodrawingarea.Allocation.Width;
+ allocHeight = logodrawingarea.Allocation.Height;
+ area = args.Event.Area;
+
+ /* Checking if allocated space is smaller than our logo */
+ if ((float) allocWidth / width > (float) allocHeight / height) {
+ ratio = (float) allocHeight / height;
+ } else {
+ ratio = (float) allocWidth / width;
+ }
+ width = (int) (width * ratio);
+ height = (int) (height * ratio);
+
+ logoX = (allocWidth / 2) - (width / 2);
+ logoY = (allocHeight / 2) - (height / 2);
+
+ /* Drawing our frame */
+ frame = logopix.ScaleSimple(width, height, InterpType.Bilinear);
+ win.DrawPixbuf (this.Style.BlackGC, frame, 0, 0,
+ logoX, logoY, width, height,
+ RgbDither.Normal, 0, 0);
+ frame.Dispose();
+ return;
+ }
}
}
diff --git a/CesarPlayer/gtk-gui/LongoMatch.Gui.CapturerBin.cs b/CesarPlayer/gtk-gui/LongoMatch.Gui.CapturerBin.cs
index b2a932a..ca111ce 100644
--- a/CesarPlayer/gtk-gui/LongoMatch.Gui.CapturerBin.cs
+++ b/CesarPlayer/gtk-gui/LongoMatch.Gui.CapturerBin.cs
@@ -17,7 +17,9 @@ namespace LongoMatch.Gui {
private Gtk.HBox capturerhbox;
- private Gtk.HBox hbox1;
+ private Gtk.DrawingArea logodrawingarea;
+
+ private Gtk.HBox hbox2;
private Gtk.HBox buttonsbox;
@@ -42,14 +44,20 @@ namespace LongoMatch.Gui {
this.capturerhbox = new Gtk.HBox();
this.capturerhbox.Name = "capturerhbox";
this.capturerhbox.Spacing = 6;
+ // Container child capturerhbox.Gtk.Box+BoxChild
+ this.logodrawingarea = new Gtk.DrawingArea();
+ this.logodrawingarea.Name = "logodrawingarea";
+ this.capturerhbox.Add(this.logodrawingarea);
+ Gtk.Box.BoxChild w1 = ((Gtk.Box.BoxChild)(this.capturerhbox[this.logodrawingarea]));
+ w1.Position = 1;
this.vbox1.Add(this.capturerhbox);
- Gtk.Box.BoxChild w1 = ((Gtk.Box.BoxChild)(this.vbox1[this.capturerhbox]));
- w1.Position = 0;
+ Gtk.Box.BoxChild w2 = ((Gtk.Box.BoxChild)(this.vbox1[this.capturerhbox]));
+ w2.Position = 0;
// Container child vbox1.Gtk.Box+BoxChild
- this.hbox1 = new Gtk.HBox();
- this.hbox1.Name = "hbox1";
- this.hbox1.Spacing = 6;
- // Container child hbox1.Gtk.Box+BoxChild
+ this.hbox2 = new Gtk.HBox();
+ this.hbox2.Name = "hbox2";
+ this.hbox2.Spacing = 6;
+ // Container child hbox2.Gtk.Box+BoxChild
this.buttonsbox = new Gtk.HBox();
this.buttonsbox.Name = "buttonsbox";
this.buttonsbox.Spacing = 6;
@@ -59,92 +67,92 @@ namespace LongoMatch.Gui {
this.recbutton.Name = "recbutton";
this.recbutton.UseUnderline = true;
// Container child recbutton.Gtk.Container+ContainerChild
- Gtk.Alignment w2 = new Gtk.Alignment(0.5F, 0.5F, 0F, 0F);
+ Gtk.Alignment w3 = new Gtk.Alignment(0.5F, 0.5F, 0F, 0F);
// Container child GtkAlignment.Gtk.Container+ContainerChild
- Gtk.HBox w3 = new Gtk.HBox();
- w3.Spacing = 2;
+ Gtk.HBox w4 = new Gtk.HBox();
+ w4.Spacing = 2;
// Container child GtkHBox.Gtk.Container+ContainerChild
- Gtk.Image w4 = new Gtk.Image();
- w4.Pixbuf = Stetic.IconLoader.LoadIcon(this, "gtk-media-record", Gtk.IconSize.Button, 20);
- w3.Add(w4);
+ Gtk.Image w5 = new Gtk.Image();
+ w5.Pixbuf = Stetic.IconLoader.LoadIcon(this, "gtk-media-record", Gtk.IconSize.Dialog, 48);
+ w4.Add(w5);
// Container child GtkHBox.Gtk.Container+ContainerChild
- Gtk.Label w6 = new Gtk.Label();
- w3.Add(w6);
- w2.Add(w3);
- this.recbutton.Add(w2);
+ Gtk.Label w7 = new Gtk.Label();
+ w4.Add(w7);
+ w3.Add(w4);
+ this.recbutton.Add(w3);
this.buttonsbox.Add(this.recbutton);
- Gtk.Box.BoxChild w10 = ((Gtk.Box.BoxChild)(this.buttonsbox[this.recbutton]));
- w10.Position = 0;
- w10.Expand = false;
- w10.Fill = false;
+ Gtk.Box.BoxChild w11 = ((Gtk.Box.BoxChild)(this.buttonsbox[this.recbutton]));
+ w11.Position = 0;
+ w11.Expand = false;
+ w11.Fill = false;
// Container child buttonsbox.Gtk.Box+BoxChild
this.pausebutton = new Gtk.Button();
this.pausebutton.CanFocus = true;
this.pausebutton.Name = "pausebutton";
this.pausebutton.UseUnderline = true;
// Container child pausebutton.Gtk.Container+ContainerChild
- Gtk.Alignment w11 = new Gtk.Alignment(0.5F, 0.5F, 0F, 0F);
- // Container child GtkAlignment.Gtk.Container+ContainerChild
- Gtk.HBox w12 = new Gtk.HBox();
- w12.Spacing = 2;
- // Container child GtkHBox.Gtk.Container+ContainerChild
- Gtk.Image w13 = new Gtk.Image();
- w13.Pixbuf = Stetic.IconLoader.LoadIcon(this, "gtk-media-pause", Gtk.IconSize.Button, 20);
+ Gtk.Alignment w12 = new Gtk.Alignment(0.5F, 0.5F, 0F, 0F);
+ // Container child GtkAlignment1.Gtk.Container+ContainerChild
+ Gtk.HBox w13 = new Gtk.HBox();
+ w13.Spacing = 2;
+ // Container child GtkHBox1.Gtk.Container+ContainerChild
+ Gtk.Image w14 = new Gtk.Image();
+ w14.Pixbuf = Stetic.IconLoader.LoadIcon(this, "gtk-media-pause", Gtk.IconSize.Dialog, 48);
+ w13.Add(w14);
+ // Container child GtkHBox1.Gtk.Container+ContainerChild
+ Gtk.Label w16 = new Gtk.Label();
+ w13.Add(w16);
w12.Add(w13);
- // Container child GtkHBox.Gtk.Container+ContainerChild
- Gtk.Label w15 = new Gtk.Label();
- w12.Add(w15);
- w11.Add(w12);
- this.pausebutton.Add(w11);
+ this.pausebutton.Add(w12);
this.buttonsbox.Add(this.pausebutton);
- Gtk.Box.BoxChild w19 = ((Gtk.Box.BoxChild)(this.buttonsbox[this.pausebutton]));
- w19.Position = 1;
- w19.Expand = false;
- w19.Fill = false;
+ Gtk.Box.BoxChild w20 = ((Gtk.Box.BoxChild)(this.buttonsbox[this.pausebutton]));
+ w20.Position = 1;
+ w20.Expand = false;
+ w20.Fill = false;
// Container child buttonsbox.Gtk.Box+BoxChild
this.stopbutton = new Gtk.Button();
this.stopbutton.CanFocus = true;
this.stopbutton.Name = "stopbutton";
this.stopbutton.UseUnderline = true;
// Container child stopbutton.Gtk.Container+ContainerChild
- Gtk.Alignment w20 = new Gtk.Alignment(0.5F, 0.5F, 0F, 0F);
- // Container child GtkAlignment.Gtk.Container+ContainerChild
- Gtk.HBox w21 = new Gtk.HBox();
- w21.Spacing = 2;
- // Container child GtkHBox.Gtk.Container+ContainerChild
- Gtk.Image w22 = new Gtk.Image();
- w22.Pixbuf = Stetic.IconLoader.LoadIcon(this, "gtk-media-stop", Gtk.IconSize.Button, 20);
+ Gtk.Alignment w21 = new Gtk.Alignment(0.5F, 0.5F, 0F, 0F);
+ // Container child GtkAlignment2.Gtk.Container+ContainerChild
+ Gtk.HBox w22 = new Gtk.HBox();
+ w22.Spacing = 2;
+ // Container child GtkHBox2.Gtk.Container+ContainerChild
+ Gtk.Image w23 = new Gtk.Image();
+ w23.Pixbuf = Stetic.IconLoader.LoadIcon(this, "gtk-media-stop", Gtk.IconSize.Dialog, 48);
+ w22.Add(w23);
+ // Container child GtkHBox2.Gtk.Container+ContainerChild
+ Gtk.Label w25 = new Gtk.Label();
+ w22.Add(w25);
w21.Add(w22);
- // Container child GtkHBox.Gtk.Container+ContainerChild
- Gtk.Label w24 = new Gtk.Label();
- w21.Add(w24);
- w20.Add(w21);
- this.stopbutton.Add(w20);
+ this.stopbutton.Add(w21);
this.buttonsbox.Add(this.stopbutton);
- Gtk.Box.BoxChild w28 = ((Gtk.Box.BoxChild)(this.buttonsbox[this.stopbutton]));
- w28.Position = 2;
- w28.Expand = false;
- w28.Fill = false;
- this.hbox1.Add(this.buttonsbox);
- Gtk.Box.BoxChild w29 = ((Gtk.Box.BoxChild)(this.hbox1[this.buttonsbox]));
- w29.Position = 0;
+ Gtk.Box.BoxChild w29 = ((Gtk.Box.BoxChild)(this.buttonsbox[this.stopbutton]));
+ w29.Position = 2;
w29.Expand = false;
w29.Fill = false;
- // Container child hbox1.Gtk.Box+BoxChild
+ this.hbox2.Add(this.buttonsbox);
+ Gtk.Box.BoxChild w30 = ((Gtk.Box.BoxChild)(this.hbox2[this.buttonsbox]));
+ w30.Position = 0;
+ w30.Expand = false;
+ w30.Fill = false;
+ // Container child hbox2.Gtk.Box+BoxChild
this.timelabel = new Gtk.Label();
this.timelabel.Name = "timelabel";
this.timelabel.Xalign = 1F;
this.timelabel.LabelProp = "Time: 0:00:00";
- this.hbox1.Add(this.timelabel);
- Gtk.Box.BoxChild w30 = ((Gtk.Box.BoxChild)(this.hbox1[this.timelabel]));
- w30.PackType = ((Gtk.PackType)(1));
- w30.Position = 1;
- w30.Expand = false;
- this.vbox1.Add(this.hbox1);
- Gtk.Box.BoxChild w31 = ((Gtk.Box.BoxChild)(this.vbox1[this.hbox1]));
+ this.hbox2.Add(this.timelabel);
+ Gtk.Box.BoxChild w31 = ((Gtk.Box.BoxChild)(this.hbox2[this.timelabel]));
+ w31.PackType = ((Gtk.PackType)(1));
w31.Position = 1;
w31.Expand = false;
- w31.Fill = false;
+ this.vbox1.Add(this.hbox2);
+ Gtk.Box.BoxChild w32 = ((Gtk.Box.BoxChild)(this.vbox1[this.hbox2]));
+ w32.Position = 1;
+ w32.Expand = false;
+ w32.Fill = false;
this.Add(this.vbox1);
if ((this.Child != null)) {
this.Child.ShowAll();
@@ -152,6 +160,7 @@ namespace LongoMatch.Gui {
this.pausebutton.Hide();
this.stopbutton.Hide();
this.Show();
+ this.logodrawingarea.ExposeEvent += new Gtk.ExposeEventHandler(this.OnLogodrawingareaExposeEvent);
this.recbutton.Clicked += new System.EventHandler(this.OnRecbuttonClicked);
this.pausebutton.Clicked += new System.EventHandler(this.OnPausebuttonClicked);
this.stopbutton.Clicked += new System.EventHandler(this.OnStopbuttonClicked);
diff --git a/CesarPlayer/gtk-gui/gui.stetic b/CesarPlayer/gtk-gui/gui.stetic
index b55567f..68bf8c9 100644
--- a/CesarPlayer/gtk-gui/gui.stetic
+++ b/CesarPlayer/gtk-gui/gui.stetic
@@ -334,7 +334,7 @@
</widget>
</child>
</widget>
- <widget class="Gtk.Bin" id="LongoMatch.Gui.CapturerBin" design-size="300 300">
+ <widget class="Gtk.Bin" id="LongoMatch.Gui.CapturerBin" design-size="356 295">
<property name="MemberName" />
<child>
<widget class="Gtk.VBox" id="vbox1">
@@ -347,6 +347,19 @@
<child>
<placeholder />
</child>
+ <child>
+ <widget class="Gtk.DrawingArea" id="logodrawingarea">
+ <property name="MemberName" />
+ <signal name="ExposeEvent" handler="OnLogodrawingareaExposeEvent" />
+ </widget>
+ <packing>
+ <property name="Position">1</property>
+ <property name="AutoSize">True</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder />
+ </child>
</widget>
<packing>
<property name="Position">0</property>
@@ -354,7 +367,7 @@
</packing>
</child>
<child>
- <widget class="Gtk.HBox" id="hbox1">
+ <widget class="Gtk.HBox" id="hbox2">
<property name="MemberName" />
<property name="Spacing">6</property>
<child>
@@ -366,7 +379,7 @@
<property name="MemberName" />
<property name="CanFocus">True</property>
<property name="Type">TextAndIcon</property>
- <property name="Icon">stock:gtk-media-record Button</property>
+ <property name="Icon">stock:gtk-media-record Dialog</property>
<property name="Label" translatable="yes" />
<property name="UseUnderline">True</property>
<signal name="Clicked" handler="OnRecbuttonClicked" />
@@ -384,7 +397,7 @@
<property name="Visible">False</property>
<property name="CanFocus">True</property>
<property name="Type">TextAndIcon</property>
- <property name="Icon">stock:gtk-media-pause Button</property>
+ <property name="Icon">stock:gtk-media-pause Dialog</property>
<property name="Label" translatable="yes" />
<property name="UseUnderline">True</property>
<signal name="Clicked" handler="OnPausebuttonClicked" />
@@ -402,14 +415,14 @@
<property name="Visible">False</property>
<property name="CanFocus">True</property>
<property name="Type">TextAndIcon</property>
- <property name="Icon">stock:gtk-media-stop Button</property>
+ <property name="Icon">stock:gtk-media-stop Dialog</property>
<property name="Label" translatable="yes" />
<property name="UseUnderline">True</property>
<signal name="Clicked" handler="OnStopbuttonClicked" />
</widget>
<packing>
<property name="Position">2</property>
- <property name="AutoSize">True</property>
+ <property name="AutoSize">False</property>
<property name="Expand">False</property>
<property name="Fill">False</property>
</packing>
@@ -438,7 +451,7 @@
</widget>
<packing>
<property name="Position">1</property>
- <property name="AutoSize">True</property>
+ <property name="AutoSize">False</property>
<property name="Expand">False</property>
<property name="Fill">False</property>
</packing>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]