[Pkg-cli-apps-commits] r5317 - in /packages/gnome-subtitles/trunk/src/GnomeSubtitles: Core/DragDrop.cs Ui/Component/ Ui/Component/ComboBoxUtil.cs Ui/Component/EncodingComboBox.cs Ui/Component/NewlineTypeComboBox.cs Ui/Component/SubtitleFormatComboBox.cs

tiago at users.alioth.debian.org tiago at users.alioth.debian.org
Sun Feb 21 18:15:35 UTC 2010


Author: tiago
Date: Sun Feb 21 18:15:28 2010
New Revision: 5317

URL: http://svn.debian.org/wsvn/pkg-cli-apps/?sc=1&rev=5317
Log:
Broken merge... sorry.

Added:
    packages/gnome-subtitles/trunk/src/GnomeSubtitles/Core/DragDrop.cs
    packages/gnome-subtitles/trunk/src/GnomeSubtitles/Ui/Component/
    packages/gnome-subtitles/trunk/src/GnomeSubtitles/Ui/Component/ComboBoxUtil.cs
    packages/gnome-subtitles/trunk/src/GnomeSubtitles/Ui/Component/EncodingComboBox.cs
    packages/gnome-subtitles/trunk/src/GnomeSubtitles/Ui/Component/NewlineTypeComboBox.cs
    packages/gnome-subtitles/trunk/src/GnomeSubtitles/Ui/Component/SubtitleFormatComboBox.cs

Added: packages/gnome-subtitles/trunk/src/GnomeSubtitles/Core/DragDrop.cs
URL: http://svn.debian.org/wsvn/pkg-cli-apps/packages/gnome-subtitles/trunk/src/GnomeSubtitles/Core/DragDrop.cs?rev=5317&op=file
==============================================================================
--- packages/gnome-subtitles/trunk/src/GnomeSubtitles/Core/DragDrop.cs (added)
+++ packages/gnome-subtitles/trunk/src/GnomeSubtitles/Core/DragDrop.cs Sun Feb 21 18:15:28 2010
@@ -1,0 +1,52 @@
+/*
+ * This file is part of Gnome Subtitles.
+ * Copyright (C) 2009 Pedro Castro
+ *
+ * Gnome Subtitles 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.
+ *
+ * Gnome Subtitles 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+using Gdk;
+using GnomeSubtitles.Ui;
+using Gtk;
+
+namespace GnomeSubtitles.Core {
+
+public class DragDrop {
+	private TargetEntry targetUriList = new TargetEntry("text/uri-list", 0, DragDropTargetUriList);
+    
+	/* Public constants */
+	public const uint DragDropTargetUriList = 0;
+
+
+	public DragDrop () {
+		Base.InitFinished += OnBaseInitFinished;
+	}
+
+
+	/* Private members */
+	
+	private void SetDropTargets () {
+		TargetEntry[] targetEntries = new TargetEntry[] { targetUriList };
+		Gtk.Drag.DestSet(Base.GetWidget(WidgetNames.SubtitleAreaVBox), DestDefaults.All, targetEntries, DragAction.Copy);
+		Gtk.Drag.DestSet(Base.GetWidget(WidgetNames.VideoAreaHBox), DestDefaults.All, targetEntries, DragAction.Copy);
+	}
+
+	private void OnBaseInitFinished () {
+		SetDropTargets();
+    }
+
+}
+
+}

Added: packages/gnome-subtitles/trunk/src/GnomeSubtitles/Ui/Component/ComboBoxUtil.cs
URL: http://svn.debian.org/wsvn/pkg-cli-apps/packages/gnome-subtitles/trunk/src/GnomeSubtitles/Ui/Component/ComboBoxUtil.cs?rev=5317&op=file
==============================================================================
--- packages/gnome-subtitles/trunk/src/GnomeSubtitles/Ui/Component/ComboBoxUtil.cs (added)
+++ packages/gnome-subtitles/trunk/src/GnomeSubtitles/Ui/Component/ComboBoxUtil.cs Sun Feb 21 18:15:28 2010
@@ -1,0 +1,41 @@
+/*
+ * This file is part of Gnome Subtitles.
+ * Copyright (C) 2007-2010 Pedro Castro
+ *
+ * Gnome Subtitles 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.
+ *
+ * Gnome Subtitles 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+using Gtk;
+
+namespace GnomeSubtitles.Ui.Component {
+
+public class ComboBoxUtil {
+
+	public static bool SeparatorFunc (TreeModel model, TreeIter iter) {
+		string text = (string)model.GetValue(iter, 0);
+		return ((text != null) && (text.CompareTo("-") == 0));
+	}
+
+	public static void InitComboBox (ComboBox comboBox) {
+		comboBox.Clear();
+		CellRendererText cell = new CellRendererText();
+		comboBox.PackStart(cell, false);
+		comboBox.AddAttribute(cell, "text", 0);
+		comboBox.Model = new ListStore(typeof(string));
+	}
+
+}
+
+}

Added: packages/gnome-subtitles/trunk/src/GnomeSubtitles/Ui/Component/EncodingComboBox.cs
URL: http://svn.debian.org/wsvn/pkg-cli-apps/packages/gnome-subtitles/trunk/src/GnomeSubtitles/Ui/Component/EncodingComboBox.cs?rev=5317&op=file
==============================================================================
--- packages/gnome-subtitles/trunk/src/GnomeSubtitles/Ui/Component/EncodingComboBox.cs (added)
+++ packages/gnome-subtitles/trunk/src/GnomeSubtitles/Ui/Component/EncodingComboBox.cs Sun Feb 21 18:15:28 2010
@@ -1,0 +1,239 @@
+/*
+ * This file is part of Gnome Subtitles.
+ * Copyright (C) 2006-2010 Pedro Castro
+ *
+ * Gnome Subtitles 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.
+ *
+ * Gnome Subtitles 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+using GnomeSubtitles.Core;
+using GnomeSubtitles.Dialog;
+using Gtk;
+using Mono.Unix;
+using System;
+using System.Collections;
+
+namespace GnomeSubtitles.Ui.Component {
+
+public class EncodingComboBox {
+
+	private ComboBox comboBox = null;
+	private int comboBoxActiveItem = 0; //Stores the last active item so we can get back to it after using Add/Remove
+
+	private ArrayList encodings = null; //Encodings present in the combo box
+	private int actionCount = 0; //Actions correspond to the initial items (including auto detection)
+	private bool hasAutoDetect = false; //Whether to add Auto Detect to the top of the item list
+	private string[] additionalActions = null; //
+	private int fixedEncoding = -1; //Codepage of an encoding that must be present (-1 if not)
+	private ArrayList configShownEncodings = null; //Encodings shown in menu from config
+
+	public EncodingComboBox (ComboBox comboBox, bool hasAutoDetect, string[] additionalActions, int fixedEncoding) {
+		this.comboBox = comboBox;
+		this.additionalActions = additionalActions;
+		this.hasAutoDetect = hasAutoDetect;
+		this.fixedEncoding = fixedEncoding;
+
+		InitComboBoxModel();
+		SetActionCount();
+		SetComboBox(Base.Config.PrefsEncodingsShownInMenu);
+		ConnectHandlers();
+	}
+
+	public EncodingComboBox (ComboBox comboBox, bool hasAutoDetect) : this(comboBox, hasAutoDetect, null, -1) {
+	}
+
+
+	/* Events */
+	
+	public event EventHandler SelectionChanged;
+	
+
+	/* Public properties */
+
+	public bool HasChosenAction {
+		get { return comboBox.Active < actionCount; }
+	}
+
+	public int ChosenAction {
+		get { return (HasChosenAction ? comboBox.Active : -1); }
+	}
+
+	public EncodingDescription ChosenEncoding {
+		get {
+			int active = comboBox.Active;
+			if (active < actionCount) //An action is active
+				return EncodingDescription.Empty;
+			else
+				return (EncodingDescription)encodings[active - (actionCount > 0 ? actionCount + 1 : 0)]; //1 for break line
+		}
+	}
+
+	public bool IsChosenCurrentLocale {
+		get {
+			if (actionCount > 0)
+				return comboBox.Active == actionCount + 1;
+			else
+				return comboBox.Active == 0;
+		}
+	}
+
+	public int ActiveSelection {
+		get { return comboBox.Active; }
+		set { SetActiveItem(value, false); }
+	}
+
+
+	/* Private members */
+
+	private void InitComboBoxModel () {
+		ComboBoxUtil.InitComboBox(comboBox);
+	}
+
+	private void SetActionCount () {
+		this.actionCount = (hasAutoDetect ? 1 : 0) + (additionalActions != null ? additionalActions.Length : 0);
+	}
+
+	private void SetComboBox (string[] names) {
+		configShownEncodings = new ArrayList(names);
+		LoadEncodings();
+		FillComboBox();
+	}
+
+	private void LoadEncodings () {
+		bool toAddFixedEncoding = (fixedEncoding != -1);
+		ArrayList encodings = new ArrayList();
+		
+		foreach (string name in configShownEncodings) {
+			EncodingDescription description = EncodingDescription.Empty;
+			if (Encodings.Find(name, ref description)) {
+				encodings.Add(description);
+				if (toAddFixedEncoding && (description.CodePage == fixedEncoding))
+					toAddFixedEncoding = false;
+			}
+		}
+
+		if (toAddFixedEncoding) {
+			EncodingDescription description = EncodingDescription.Empty;
+			if (Encodings.Find(fixedEncoding, ref description))
+				encodings.Add(description);		
+		}
+
+		encodings.Sort();
+		encodings.Insert(0, Encodings.SystemDefault);
+
+		this.encodings = encodings;
+	}
+
+	private void FillComboBox () {
+		DisconnectComboBoxChangedSignal();
+
+		(comboBox.Model as ListStore).Clear();
+
+		int activeItem = comboBoxActiveItem;
+		int currentItem = 0;
+
+		/* Add auto detect */
+		if (hasAutoDetect) {
+			AddAutoDetect();
+			currentItem ++;
+		}
+
+		/* Add additional actions */
+		if (additionalActions != null) {
+			foreach (string additionalAction in additionalActions) {
+				comboBox.AppendText(additionalAction);
+				currentItem++;
+			}
+		}
+
+		if (currentItem != 0) {
+			comboBox.AppendText("-");
+			currentItem++;
+		}
+
+		/* Add encodings */
+		foreach (EncodingDescription encoding in encodings) {
+			comboBox.AppendText(encoding.Description + " (" + encoding.Name + ")");
+			if (encoding.CodePage == fixedEncoding) {
+				activeItem = currentItem;
+			}
+			currentItem++;
+		}
+
+		/* Add add/remove action */
+		comboBox.AppendText("-");
+		comboBox.AppendText(Catalog.GetString("Add or Remove..."));
+
+		SetActiveItem(activeItem, false); //Don't use silent change because the signal is already disabled
+
+		ConnectComboBoxChangedSignal();
+	}
+
+	private void AddAutoDetect () {
+		comboBox.AppendText(Catalog.GetString("Auto Detected"));
+	}
+
+	private void SetActiveItem (int item, bool silent) {
+		int itemCount = comboBox.Model.IterNChildren();
+		if (itemCount == 0)
+			return;
+
+		if (silent)
+			DisconnectComboBoxChangedSignal();
+
+		comboBoxActiveItem = (item < itemCount - 2 ? item : 0);
+		comboBox.Active = comboBoxActiveItem;
+
+		if (silent)
+			ConnectComboBoxChangedSignal();
+	}
+
+	/* Event members */
+	
+	#pragma warning disable 169		//Disables warning about handlers not being used
+
+	private void ConnectHandlers () {
+		comboBox.RowSeparatorFunc = ComboBoxUtil.SeparatorFunc;
+	}
+
+	private void ConnectComboBoxChangedSignal () {
+		comboBox.Changed += OnComboBoxChanged;
+	}
+
+	private void DisconnectComboBoxChangedSignal () {
+		comboBox.Changed -= OnComboBoxChanged;
+	}
+
+	private void OnComboBoxChanged (object o, EventArgs args) {
+		ComboBox comboBox = o as ComboBox;
+		int itemCount = comboBox.Model.IterNChildren();
+		int selectedItem = comboBox.Active;
+
+		if (selectedItem == (itemCount - 1)) {
+			EncodingsDialog dialog = Base.Dialogs.Get(typeof(EncodingsDialog)) as EncodingsDialog;
+			dialog.Show();
+			dialog.WaitForResponse();
+			SetComboBox(dialog.ChosenNames);
+			//SetActiveItem(comboBoxActiveItem, true);
+		}
+		else {
+			comboBoxActiveItem = selectedItem;
+			if (SelectionChanged != null)
+				SelectionChanged(o, args);
+		}
+	}
+
+}
+
+}

Added: packages/gnome-subtitles/trunk/src/GnomeSubtitles/Ui/Component/NewlineTypeComboBox.cs
URL: http://svn.debian.org/wsvn/pkg-cli-apps/packages/gnome-subtitles/trunk/src/GnomeSubtitles/Ui/Component/NewlineTypeComboBox.cs?rev=5317&op=file
==============================================================================
--- packages/gnome-subtitles/trunk/src/GnomeSubtitles/Ui/Component/NewlineTypeComboBox.cs (added)
+++ packages/gnome-subtitles/trunk/src/GnomeSubtitles/Ui/Component/NewlineTypeComboBox.cs Sun Feb 21 18:15:28 2010
@@ -1,0 +1,181 @@
+/*
+ * This file is part of Gnome Subtitles.
+ * Copyright (C) 2006-2010 Pedro Castro
+ *
+ * Gnome Subtitles 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.
+ *
+ * Gnome Subtitles 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+using Gtk;
+using Mono.Unix;
+using SubLib.Core.Domain;
+using System;
+
+namespace GnomeSubtitles.Ui.Component {
+
+public class NewlineTypeComboBox {
+
+	private ComboBox comboBox = null;
+	private NewlineType newlineTypeToSelect = NewlineType.Unknown;
+	private string[] additionalActions = null;
+
+	public NewlineTypeComboBox (ComboBox comboBox, NewlineType newlineTypeToSelect, string[] additionalActions) {
+		this.comboBox = comboBox;
+		this.newlineTypeToSelect = newlineTypeToSelect;
+		this.additionalActions = additionalActions;
+
+		InitComboBoxModel();
+		FillComboBox();
+		ConnectHandlers();
+	}
+
+	/* Events */
+
+	public event EventHandler SelectionChanged;
+
+
+	/* Public properties */
+
+	public bool HasChosenAction {
+		get { return comboBox.Active < GetActionCount(); }
+	}
+
+	public int ChosenAction {
+		get { return (HasChosenAction ? comboBox.Active : -1); }
+	}
+
+	public NewlineType ChosenNewlineType {
+		get {
+			int active = comboBox.Active;
+			int actionCount = GetActionCount();
+			if (active < actionCount) //An action is active
+				return NewlineType.Unknown;
+			else {
+				int newlineTypePosition = active - (actionCount > 0 ? actionCount + 1 : 0) + 1; //plus 1 because NewlineType 0 is unknown
+				return (NewlineType)Enum.ToObject(typeof(NewlineType), newlineTypePosition);
+			}
+		}
+		set {
+			int actionCount = GetActionCount();
+			int position = (int)value - 1 + (actionCount > 0 ? actionCount + 1 : 0);
+			this.ActiveSelection = position;	
+		}
+	}
+
+	public int ActiveSelection {
+		get { return comboBox.Active; }
+		set { SetActiveItem(value, false); }
+	}
+
+
+	/* Private members */
+
+	private void InitComboBoxModel () {
+		ComboBoxUtil.InitComboBox(comboBox);
+	}
+
+	private void FillComboBox () {
+		DisconnectComboBoxChangedSignal();
+
+		(comboBox.Model as ListStore).Clear();
+
+		bool hasAdditionalActions = (additionalActions != null) && (additionalActions.Length > 0);
+
+		/* Add additional actions */
+		if (hasAdditionalActions) {
+			foreach (string additionalAction in additionalActions) {
+				comboBox.AppendText(additionalAction);
+			}
+			comboBox.AppendText("-");
+		}
+
+		/* Prepare newline types to add */
+		string mac = "Macintosh";
+		string unix = "Unix";
+		string windows = "Windows";
+		string systemDefault = " (" + Catalog.GetString("System Default") + ")";
+		NewlineType systemNewline = Core.Util.GetSystemNewlineType();
+		SetSystemNewlineSuffix(systemNewline, ref mac, ref unix, ref windows, systemDefault);
+
+		/* Add newline types */
+		comboBox.AppendText(mac);
+		comboBox.AppendText(unix);
+		comboBox.AppendText(windows);
+
+		if (newlineTypeToSelect != NewlineType.Unknown) {
+			int activeItem = (int)newlineTypeToSelect - 1 + (hasAdditionalActions ? additionalActions.Length + 1 : 0);
+			SetActiveItem(activeItem, false); //Don't use silent change because the signal is already disabled
+		}
+
+		ConnectComboBoxChangedSignal();
+	}
+
+	private void SetActiveItem (int item, bool silent) {
+		int itemCount = comboBox.Model.IterNChildren();
+		if (itemCount == 0)
+			return;
+
+		if (silent)
+			DisconnectComboBoxChangedSignal();
+
+		comboBox.Active = item;
+
+		if (silent)
+			ConnectComboBoxChangedSignal();
+	}
+
+	private int GetActionCount () {
+		return (additionalActions != null ? additionalActions.Length : 0);
+	}
+
+	private void SetSystemNewlineSuffix (NewlineType newline, ref string mac, ref string unix, ref string windows, string suffix) {
+		switch (newline) {
+			case NewlineType.Macintosh:
+				mac += suffix;
+				break;
+			case NewlineType.Unix:
+				unix += suffix;
+				break;
+			case NewlineType.Windows:
+				windows += suffix;
+				break;
+		}
+	}
+
+
+	/* Event members */
+	
+	#pragma warning disable 169		//Disables warning about handlers not being used
+
+	private void ConnectHandlers () {
+		comboBox.RowSeparatorFunc = ComboBoxUtil.SeparatorFunc;
+	}
+
+	private void ConnectComboBoxChangedSignal () {
+		comboBox.Changed += OnComboBoxChanged;
+	}
+
+	private void DisconnectComboBoxChangedSignal () {
+		comboBox.Changed -= OnComboBoxChanged;
+	}
+
+	private void OnComboBoxChanged (object o, EventArgs args) {
+		if (SelectionChanged != null) {
+			SelectionChanged(o, args);
+		}
+	}
+
+}
+
+}

Added: packages/gnome-subtitles/trunk/src/GnomeSubtitles/Ui/Component/SubtitleFormatComboBox.cs
URL: http://svn.debian.org/wsvn/pkg-cli-apps/packages/gnome-subtitles/trunk/src/GnomeSubtitles/Ui/Component/SubtitleFormatComboBox.cs?rev=5317&op=file
==============================================================================
--- packages/gnome-subtitles/trunk/src/GnomeSubtitles/Ui/Component/SubtitleFormatComboBox.cs (added)
+++ packages/gnome-subtitles/trunk/src/GnomeSubtitles/Ui/Component/SubtitleFormatComboBox.cs Sun Feb 21 18:15:28 2010
@@ -1,0 +1,162 @@
+/*
+ * This file is part of Gnome Subtitles.
+ * Copyright (C) 2006-2010 Pedro Castro
+ *
+ * Gnome Subtitles 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.
+ *
+ * Gnome Subtitles 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+using Gtk;
+using SubLib.Core.Domain;
+using System;
+
+namespace GnomeSubtitles.Ui.Component {
+
+public class SubtitleFormatComboBox {
+
+	private ComboBox comboBox = null;
+	private SubtitleTypeInfo[] subtitleTypes = null;
+	private string[] additionalActions = null; //
+	private SubtitleType fixedSubtitleType = SubtitleType.Unknown; //A subtitle type that must be selected
+
+	public SubtitleFormatComboBox (ComboBox comboBox, SubtitleType fixedSubtitleType, string[] additionalActions) {
+		this.comboBox = comboBox;
+		this.fixedSubtitleType = fixedSubtitleType;
+		this.additionalActions = additionalActions;
+
+		InitComboBoxModel();
+		SetComboBox();
+		ConnectHandlers();
+	}
+
+	/* Events */
+
+	public event EventHandler SelectionChanged;
+
+
+	/* Public properties */
+
+	public bool HasChosenAction {
+		get { return comboBox.Active < GetActionCount(); }
+	}
+
+	public int ChosenAction {
+		get { return (HasChosenAction ? comboBox.Active : -1); }
+	}
+
+	public SubtitleType ChosenSubtitleType {
+		get {
+			int active = comboBox.Active;
+			int actionCount = GetActionCount();
+			if (active < actionCount) //An action is active
+				return SubtitleType.Unknown;
+			else
+				return subtitleTypes[active - (actionCount > 0 ? actionCount + 1 : 0)].Type; //1 for break line
+		}
+	}
+
+	public int ActiveSelection {
+		get { return comboBox.Active; }
+		set { SetActiveItem(value, false); }
+	}
+
+
+	/* Private members */
+
+	private void InitComboBoxModel () {
+		ComboBoxUtil.InitComboBox(comboBox);
+	}
+
+	private void SetComboBox () {
+		subtitleTypes = Subtitles.AvailableTypesSorted;
+		FillComboBox();
+	}
+
+	private void FillComboBox () {
+		DisconnectComboBoxChangedSignal();
+
+		(comboBox.Model as ListStore).Clear();
+
+		int currentItem = 0;
+		int activeItem = 0;
+
+		bool hasAdditionalActions = (additionalActions != null) && (additionalActions.Length > 0);
+
+		/* Add additional actions */
+		if (hasAdditionalActions) {
+			foreach (string additionalAction in additionalActions) {
+				comboBox.AppendText(additionalAction);
+			}
+			comboBox.AppendText("-");
+			currentItem += additionalActions.Length + 1;
+		}
+
+		/* Add subtitle formats */
+		foreach (SubtitleTypeInfo typeInfo in subtitleTypes) {
+			comboBox.AppendText(typeInfo.Name + " (" + typeInfo.ExtensionsAsText + ")");
+			if (typeInfo.Type == fixedSubtitleType) {
+				activeItem = currentItem;
+			}
+			currentItem++;
+		}
+
+		SetActiveItem(activeItem, false); //Don't use silent change because the signal is already disabled
+
+		ConnectComboBoxChangedSignal();
+	}
+
+	private void SetActiveItem (int item, bool silent) {
+		int itemCount = comboBox.Model.IterNChildren();
+		if (itemCount == 0)
+			return;
+
+		if (silent)
+			DisconnectComboBoxChangedSignal();
+
+		comboBox.Active = item;
+
+		if (silent)
+			ConnectComboBoxChangedSignal();
+	}
+
+	private int GetActionCount () {
+		return (additionalActions != null ? additionalActions.Length : 0);
+	}
+
+
+	/* Event members */
+	
+	#pragma warning disable 169		//Disables warning about handlers not being used
+
+	private void ConnectHandlers () {
+		comboBox.RowSeparatorFunc = ComboBoxUtil.SeparatorFunc;
+	}
+
+	private void ConnectComboBoxChangedSignal () {
+		comboBox.Changed += OnComboBoxChanged;
+	}
+
+	private void DisconnectComboBoxChangedSignal () {
+		comboBox.Changed -= OnComboBoxChanged;
+	}
+
+	private void OnComboBoxChanged (object o, EventArgs args) {
+		if (SelectionChanged != null) {
+			SelectionChanged(o, args);
+		}
+	}
+
+}
+
+}




More information about the Pkg-cli-apps-commits mailing list