[transmageddon] Add initial language chooser dialog. Fix choosing second file in UI
- From: Christian Fredrik Kalager Schaller <uraeus src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [transmageddon] Add initial language chooser dialog. Fix choosing second file in UI
- Date: Wed, 23 Jan 2013 20:46:13 +0000 (UTC)
commit a89d14e1b324dba1108cd3cfddd113dad0e083a5
Author: Christian Fredrik Kalager Schaller <uraeus linuxrisin org>
Date: Wed Jan 23 21:45:34 2013 +0100
Add initial language chooser dialog. Fix choosing second file in UI
src/langchooser.py | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++
src/transmageddon.py | 14 +++++++++++-
2 files changed, 68 insertions(+), 1 deletions(-)
---
diff --git a/src/langchooser.py b/src/langchooser.py
new file mode 100644
index 0000000..409a90b
--- /dev/null
+++ b/src/langchooser.py
@@ -0,0 +1,55 @@
+import os
+from gi.repository import Gtk, GLib, Gst, GstTag
+
+class languagechooser(Gtk.Dialog):
+ def __init__(self, parent):
+ self.languageui = Gtk.Builder()
+ self.languageui.add_from_file("transmageddon-language-chooser.ui")
+ langscroll = self.languageui.get_object("langscroll")
+ cancelbutton = self.languageui.get_object("cancelbutton")
+ selectbutton = self.languageui.get_object("selectbutton")
+
+ self.languageui.connect_signals(self) # Initialize User Interface
+ self.langcode=None # this will hold the selected language value
+
+ store = Gtk.ListStore(str)
+ self.langcodeList=GstTag.tag_get_language_codes()
+ langcontents = []
+ for item in self.langcodeList:
+ langcontents.append([GstTag.tag_get_language_name(item)])
+ for act in langcontents:
+ store.append([act[0]])
+
+ self.langview = Gtk.TreeView(store)
+ self.langview.set_reorderable(False)
+ self.langview.set_headers_visible(False)
+
+ langscroll.add(self.langview)
+ self.create_columns(self.langview)
+ self.languagewindow = self.languageui.get_object("languageui")
+ self.languagewindow.set_modal(True)
+ self.languagewindow.set_transient_for(parent)
+
+ self.languagewindow.show_all()
+
+ def create_columns(self, treeView):
+ rendererText = Gtk.CellRendererText()
+ column = Gtk.TreeViewColumn(None, rendererText, text=0)
+ column.set_sort_indicator(False)
+ self.langview.append_column(column)
+
+ def on_cancelbutton_clicked(self, widget):
+ self.languagewindow.destroy()
+
+
+ def on_selectbutton_clicked(self, widget):
+ language=self.langview.get_selection()
+ (model, pathlist) = language.get_selected_rows()
+ for path in pathlist :
+ tree_iter = model.get_iter(path)
+ value = model.get_value(tree_iter,0)
+ numvalue=path.to_string()
+ self.langcode=self.langcodeList[int(numvalue)]
+ self.languagewindow.destroy()
+
+
diff --git a/src/transmageddon.py b/src/transmageddon.py
index 9445c28..a197b70 100644
--- a/src/transmageddon.py
+++ b/src/transmageddon.py
@@ -42,6 +42,7 @@ import about
import presets
import utils
import datetime
+import langchooser
major, minor, patch, micro = Gst.version()
if (major == 1) and (patch < 0):
@@ -631,6 +632,12 @@ class TransmageddonUI(Gtk.ApplicationWindow):
self.haveaudio=True
self.audiodata.append(self.add_audiodata_row(i.get_channels(), i.get_sample_rate(), i.get_caps(), False, streamid, False, False, i.get_language()))
if self.audiodata[self.audiostreamcounter]['language']== None:
+ # load language setting ui
+ output=langchooser.languagechooser(self)
+ output.languagewindow.run()
+ langcode=output.langcode
+ print(langcode)
+
self.audiodata[self.audiostreamcounter]['language']=_("Unknown language")
if self.audiostreamcounter > 0:
combo = Gtk.ComboBoxText.new()
@@ -751,7 +758,12 @@ class TransmageddonUI(Gtk.ApplicationWindow):
# define the behaviour of the other buttons
def on_FileChooser_file_set(self, widget):
self.filename = self.builder.get_object ("FileChooser").get_filename()
- self.audiodata = []
+ # These two list objects will hold all crucial media data in the form of python dictionaries.
+ self.audiodata =[]
+ self.videodata =[]
+ self.audiostreamids=[] # (list of stream ids)
+ self.videostreamids=[]
+ self.audiostreamcounter=-1
if self.filename is not None:
self.haveaudio=False #make sure to reset these for each file
self.havevideo=False #
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]