[chronojump] Camera selection on preferences
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Camera selection on preferences
- Date: Wed, 1 May 2013 04:24:53 +0000 (UTC)
commit dda889c6368a2e346adee5e7f0945010f16a0c9b
Author: Xavier de Blas <xaviblas gmail com>
Date: Wed May 1 06:24:38 2013 +0200
Camera selection on preferences
glade/chronojump.glade | 72 ++++++++++++++++++++++++++++++--------------
src/Makefile.am | 1 +
src/constants.cs | 2 +
src/gui/chronojump.cs | 51 ++++++++-----------------------
src/gui/preferences.cs | 23 ++++++++++++++-
src/sqlite/main.cs | 14 ++++++++-
src/sqlite/preferences.cs | 1 +
src/utilVideo.cs | 44 +++++++++++++++++++++++++++
8 files changed, 145 insertions(+), 63 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index b0f05f6..28b01be 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -6319,29 +6319,6 @@ Second Chronopic to platforms.</property>
<property name="position">2</property>
</packing>
</child>
- <child>
- <widget class="GtkButton"
id="button_video_source">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property
name="use_action_appearance">False</property>
- <signal name="clicked"
handler="on_button_video_source_clicked" swapped="no"/>
- <child>
- <widget class="GtkImage" id="image31">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="stock">gtk-preferences</property>
- <property name="icon-size">2</property>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="pack_type">end</property>
- <property name="position">3</property>
- </packing>
- </child>
</widget>
<packing>
<property name="left_attach">2</property>
@@ -25430,6 +25407,55 @@ show elevation as:</property>
<property name="type">tab</property>
</packing>
</child>
+ <child>
+ <widget class="GtkVBox" id="vbox5">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">8</property>
+ <property name="spacing">12</property>
+ <child>
+ <widget class="GtkLabel" id="label11">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Select the camera</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="hbox_combo_camera">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <placeholder/>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label9">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Camera</property>
+ </widget>
+ <packing>
+ <property name="position">3</property>
+ <property name="tab_fill">False</property>
+ <property name="type">tab</property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="expand">True</property>
diff --git a/src/Makefile.am b/src/Makefile.am
index eff3ae5..23f5d6f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -198,6 +198,7 @@ FILES = \
utilAll.cs\
utilDate.cs\
utilGtk.cs\
+ utilVideo.cs\
constants.cs\
report.cs\
sport.cs\
diff --git a/src/constants.cs b/src/constants.cs
index 1f04351..d2e0e57 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -567,6 +567,8 @@ public class Constants
public static string RunStartInitialSpeedYes = Catalog.GetString("Running start. Started with initial
speed.");
public static string RunStartInitialSpeedNo = Catalog.GetString("Standing start. Started without
initial speed.");
+ public static string CameraNotFound = Catalog.GetString("Sorry, no cameras found.");
+
public enum BellModes {
JUMPS, RUNS, ENCODER
}
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index e0061ef..5daf766 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -2606,13 +2606,17 @@ public partial class ChronoJumpWindow
}
- private void on_preferences_activate (object o, EventArgs args) {
+ private void on_preferences_activate (object o, EventArgs args)
+ {
+ string [] videoDevices = UtilVideo.GetVideoDevices();
+
PreferencesWindow myWin = PreferencesWindow.Show(
prefsDigitsNumber, showHeight, showPower, showInitialSpeed, showAngle,
showQIndex, showDjIndex,
askDeletion, weightPercentPreferred, heightPreferred, metersSecondsPreferred,
//System.Threading.Thread.CurrentThread.CurrentUICulture.ToString(),
SqlitePreferences.Select("language"),
- encoderPropulsive, encoderSmoothEccCon, encoderSmoothCon
+ encoderPropulsive, encoderSmoothEccCon, encoderSmoothCon,
+ videoDevices, videoDeviceNum
);
myWin.Button_accept.Clicked += new EventHandler(on_preferences_accepted);
}
@@ -2699,6 +2703,11 @@ public partial class ChronoJumpWindow
encoderSmoothCon = Convert.ToDouble ( Util.ChangeDecimalSeparator (
SqlitePreferences.Select("encoderSmoothCon") ) );
+ videoDeviceNum = Convert.ToInt32(SqlitePreferences.Select("videoDevice"));
+ if(checkbutton_video.Active) {
+ videoCapturePrepare();
+ }
+
//change language works on windows. On Linux let's change the locale
//if(UtilAll.IsWindows())
// languageChange();
@@ -2798,7 +2807,7 @@ public partial class ChronoJumpWindow
videoCapturePrepare();
}
- int videoSourceNum = 0;
+ int videoDeviceNum = 0;
private void videoCapturePrepare() {
CapturePropertiesStruct s = new CapturePropertiesStruct();
@@ -2818,7 +2827,7 @@ Log.WriteLine("videoCapturePPPPPPPPPPPPPPPPPrepare");
Log.WriteLine(dev.DeviceType.ToString());
}
- s.DeviceID = devices[videoSourceNum].ID;
+ s.DeviceID = devices[videoDeviceNum].ID;
capturer.CaptureProperties = s;
@@ -2836,40 +2845,6 @@ Log.WriteLine("videoCapturePPPPPPPPPPPPPPPPPrepare");
capturer.Run();
}
- private void on_button_video_source_clicked (object o, EventArgs args) {
- List<LongoMatch.Video.Utils.Device> devices =
LongoMatch.Video.Utils.Device.ListVideoDevices();
- string [] devicesStr = new String[devices.Count];
- int count = 0;
-Log.WriteLine("yessssssssssssssssss");
- foreach(LongoMatch.Video.Utils.Device dev in devices) {
- devicesStr[count++] = dev.ID.ToString();
- Log.WriteLine(dev.ID.ToString());
- }
-
- if(count == 0)
- new DialogMessage(Constants.MessageTypes.WARNING, Catalog.GetString("Sorry, No
cameras found."));
- else {
- genericWin = GenericWindow.Show(
- Catalog.GetString("Select video source"),
- Constants.GenericWindowShow.COMBO);
- genericWin.SetComboValues(devicesStr, devicesStr[0]);
- genericWin.ShowCombo(true);
- genericWin.Button_accept.Clicked += new EventHandler(on_button_video_source_accepted);
- genericWin.ShowNow();
- }
- }
-
- private void on_button_video_source_accepted (object o, EventArgs args) {
- List<LongoMatch.Video.Utils.Device> devices =
LongoMatch.Video.Utils.Device.ListVideoDevices();
- int count = 0;
- foreach(LongoMatch.Video.Utils.Device dev in devices) {
- if(dev.ID.ToString() == genericWin.GetComboSelected)
- videoSourceNum = count;
- count ++;
- }
- genericWin.HideAndNull();
- }
-
private void changeVideoButtons(bool myVideo) {
image_video_yes.Visible = myVideo;
diff --git a/src/gui/preferences.cs b/src/gui/preferences.cs
index 6e3e277..52232f1 100644
--- a/src/gui/preferences.cs
+++ b/src/gui/preferences.cs
@@ -67,6 +67,9 @@ public class PreferencesWindow {
// [Widget] Gtk.Box hbox_combo_language;
// [Widget] Gtk.ComboBox combo_language;
+ [Widget] Gtk.Box hbox_combo_camera;
+ [Widget] Gtk.ComboBox combo_camera;
+
[Widget] Gtk.Button button_accept;
static PreferencesWindow PreferencesWindowBox;
@@ -96,7 +99,8 @@ public class PreferencesWindow {
static public PreferencesWindow Show (int digitsNumber, bool showHeight, bool showPower,
bool showInitialSpeed, bool showAngle, bool showQIndex, bool showDjIndex,
bool askDeletion, bool weightStatsPercent, bool heightPreferred, bool
metersSecondsPreferred,
- string language, bool encoderPropulsive, double encoderSmoothEccCon, double
encoderSmoothCon)
+ string language, bool encoderPropulsive, double encoderSmoothEccCon, double
encoderSmoothCon,
+ string [] videoDevices, int videoDeviceNum)
{
if (PreferencesWindowBox == null) {
PreferencesWindowBox = new PreferencesWindow ();
@@ -107,6 +111,8 @@ public class PreferencesWindow {
// PreferencesWindowBox.createComboLanguage(language);
//else
PreferencesWindowBox.hideLanguageStuff();
+
+ PreferencesWindowBox.createComboCamera(videoDevices, videoDeviceNum);
string [] decs = {"1", "2", "3"};
PreferencesWindowBox.combo_decimals.Active = UtilGtk.ComboMakeActive(decs,
digitsNumber.ToString());
@@ -182,6 +188,20 @@ public class PreferencesWindow {
return PreferencesWindowBox;
}
+ private void createComboCamera(string [] devices, int current) {
+ combo_camera = ComboBox.NewText ();
+
+ if(devices.Length == 0) {
+ devices = Util.StringToStringArray(Constants.CameraNotFound);
+ current = 0;
+ }
+
+ UtilGtk.ComboUpdate(combo_camera, devices, "");
+ hbox_combo_camera.PackStart(combo_camera, true, true, 0);
+ hbox_combo_camera.ShowAll();
+ combo_camera.Active = UtilGtk.ComboMakeActive(devices, devices[current]);
+ }
+
private void createComboLanguage(string myLanguageCode) {
/*
combo_language = ComboBox.NewText ();
@@ -372,6 +392,7 @@ public class PreferencesWindow {
(double) PreferencesWindowBox.spin_encoder_smooth_ecc_con.Value), true);
SqlitePreferences.Update("encoderSmoothCon", Util.ConvertToPoint(
(double) PreferencesWindowBox.spin_encoder_smooth_con.Value), true);
+ SqlitePreferences.Update("videoDevice", UtilGtk.ComboGetActivePos(combo_camera).ToString(),
true);
Sqlite.Close();
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index a860b4c..af87036 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -72,7 +72,7 @@ class Sqlite
* Important, change this if there's any update to database
* Important2: if database version get numbers higher than 1, check if the comparisons with
currentVersion works ok
*/
- static string lastChronojumpDatabaseVersion = "0.91";
+ static string lastChronojumpDatabaseVersion = "0.92";
public Sqlite() {
}
@@ -1240,6 +1240,17 @@ class Sqlite
currentVersion = "0.91";
}
+ if(currentVersion == "0.91") {
+ dbcon.Open();
+
+ SqlitePreferences.Insert("videoDevice", "0");
+ Log.WriteLine("Added videoDevice to preferences");
+
+ SqlitePreferences.Update ("databaseVersion", "0.92", true);
+ dbcon.Close();
+
+ currentVersion = "0.92";
+ }
}
//if changes are made here, remember to change also in CreateTables()
@@ -1378,6 +1389,7 @@ class Sqlite
SqliteCountry.initialize();
//changes [from - to - desc]
+ //0.91 - 0.92 Converted DB to 0.92 Added videoDevice to preferences
//0.90 - 0.91 Converted DB to 0.91 Encoder Squat 75% -> 100%
//0.89 - 0.90 Converted DB to 0.90 Preferences added propulsive and encoder smooth
//0.88 - 0.89 Converted DB to 0.89 Added encoder exercise: Free
diff --git a/src/sqlite/preferences.cs b/src/sqlite/preferences.cs
index 9413899..143383e 100644
--- a/src/sqlite/preferences.cs
+++ b/src/sqlite/preferences.cs
@@ -74,6 +74,7 @@ class SqlitePreferences : Sqlite
Insert ("encoderPropulsive", "True");
Insert ("encoderSmoothEccCon", "0.6");
Insert ("encoderSmoothCon", "0.7");
+ Insert ("videoDevice", "0"); //first
}
public static void Insert(string myName, string myValue)
diff --git a/src/utilVideo.cs b/src/utilVideo.cs
new file mode 100644
index 0000000..ea3ea6f
--- /dev/null
+++ b/src/utilVideo.cs
@@ -0,0 +1,44 @@
+/*
+ * This file is part of ChronoJump
+ *
+ * ChronoJump is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * ChronoJump 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU 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
+ *
+ * Copyright (C) 2004-2012 Xavier de Blas <xaviblas gmail com>
+ */
+
+using System;
+//using System.Data;
+using System.Text; //StringBuilder
+using System.Collections; //ArrayList
+using System.Collections.Generic; //List
+using System.Diagnostics; //for detect OS
+using System.IO; //for detect OS
+
+//this class tries to be a space for methods that are used in different classes
+public class UtilVideo
+{
+ public static string [] GetVideoDevices () {
+ List<LongoMatch.Video.Utils.Device> devices =
LongoMatch.Video.Utils.Device.ListVideoDevices();
+ string [] devicesStr = new String[devices.Count];
+ int count = 0;
+ Log.WriteLine("yessssssssssssssssss");
+ foreach(LongoMatch.Video.Utils.Device dev in devices) {
+ devicesStr[count++] = dev.ID.ToString();
+ Log.WriteLine(dev.ID.ToString());
+ }
+ return devicesStr;
+ }
+
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]