[transmageddon] Use glade file for the source combobox, refactored code to populate source liststore



commit fc57a5cf961de89a72f4c58d956adb02341f81fa
Author: Alberto Ruiz <aruiz gnome org>
Date:   Sun Mar 16 16:27:08 2014 +0100

    Use glade file for the source combobox, refactored code to populate source liststore

 src/transmageddon.py |   74 +++++++++++++-------------------------------------
 src/transmageddon.ui |   26 +++++++++++++++++-
 2 files changed, 44 insertions(+), 56 deletions(-)
---
diff --git a/src/transmageddon.py b/src/transmageddon.py
index 3071a98..2b4e077 100644
--- a/src/transmageddon.py
+++ b/src/transmageddon.py
@@ -1353,71 +1353,35 @@ class TransmageddonUI(Gtk.ApplicationWindow):
            self.finder_disc_lost = self.finder.connect("disc-lost",
                                                         self.on_disc_lost)
 
+       theme = Gtk.IconTheme.get_default()
+       size= Gtk.icon_size_lookup(Gtk.IconSize.MENU)[1]
+       fileopen=theme.load_icon(Gtk.STOCK_OPEN, size, 0)
+       liststore = Gtk.ListStore(GdkPixbuf.Pixbuf,
+                                 GObject.TYPE_STRING,
+                                 GObject.TYPE_STRING,
+                                 GObject.TYPE_INT)
+       liststore.append([None, "", "", 0])
+       liststore.append([fileopen, "Choose File...", "", 1])
+
        try:
-         lsdvdexist = which.which("lsdvd")
+           lsdvdexist = which.which("lsdvd")
        except:
-         lsdvdexist = False
+           lsdvdexist = False
 
        if len(self.dvdname) > 0 and lsdvdexist: # only use this option is there is a DVD and ldvd is 
installed
-           theme = Gtk.IconTheme.get_default()
-           size= Gtk.icon_size_lookup(Gtk.IconSize.MENU)[1]
-           cdrom=theme.load_icon(Gtk.STOCK_CDROM, size, 0)
-           fileopen=theme.load_icon(Gtk.STOCK_OPEN, size, 0)
-
-
-           liststore = Gtk.ListStore(GdkPixbuf.Pixbuf, GObject.TYPE_STRING, GObject.TYPE_STRING, 
GObject.TYPE_INT)
-           liststore.append([None, "", "", 0])
-           liststore.append([fileopen, "Choose File...", "", 1])
-           x=0
+           x = 0
            while x < len(self.dvdname):
                # The code below assume further item numbers are always DVD change,
                # if that ever change be sure to change logic
                liststore.append([cdrom, self.dvdname[x], self.dvddevice[x],  2+x])
-               x=x+1
-           self.combo = Gtk.ComboBox(model=liststore)
-
-           renderer_text = Gtk.CellRendererText()
-           renderer_pixbuf = Gtk.CellRendererPixbuf()
-
-           self.combo.pack_start(renderer_pixbuf, False)
-           self.combo.pack_start(renderer_text, True)
-           self.combo.add_attribute(renderer_pixbuf, 'pixbuf', 0)
-           self.combo.add_attribute(renderer_text, 'text', 1)
-                
-           self.combo.set_active(0)
-           self.combo.connect("changed", self.on_source_changed)
-       else:
-           theme = Gtk.IconTheme.get_default()
-           size= Gtk.icon_size_lookup(Gtk.IconSize.MENU)[1]
-           fileopen=theme.load_icon(Gtk.STOCK_OPEN, size, 0)
+               x += 1
 
+       self.combo = self.builder.get_object ("combo")
+       self.combo.set_model (liststore)
+       self.combo.connect("changed", self.on_source_changed)
+       self.combo.show_all()
 
-           liststore = Gtk.ListStore(GdkPixbuf.Pixbuf, GObject.TYPE_STRING, GObject.TYPE_STRING, 
GObject.TYPE_INT)
-           liststore.append([None, "", "", 0])
-           liststore.append([fileopen, "Choose File...", "", 1])
-
-           self.combo = Gtk.ComboBox(model=liststore)
-
-           renderer_text = Gtk.CellRendererText()
-           renderer_pixbuf = Gtk.CellRendererPixbuf()
-
-           self.combo.pack_start(renderer_pixbuf, False)
-           self.combo.pack_start(renderer_text, True)
-           self.combo.add_attribute(renderer_pixbuf, 'pixbuf', 0)
-           self.combo.add_attribute(renderer_text, 'text', 1)
-                
-           self.combo.set_active(0)
-           self.combo.connect("changed", self.on_source_changed)
-
-
-          
-       #if not self.source_hbox:
-       self.source_hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
-       self.source_hbox.pack_start(self.combo, True, True, 0)
-       self.table1.attach(self.source_hbox, 2, 3, 0, 1) #, yoptions = GTK_FILL)
-        
-       # Attach and show the source
-       self.source_hbox.show_all()
+       self.table1.attach(self.combo, 2, 3, 0, 1)
 
    def setup_audiovbox(self, streamcounter): # creates the list of audiostreams ui
        """
diff --git a/src/transmageddon.ui b/src/transmageddon.ui
index e88535b..aa0bce7 100644
--- a/src/transmageddon.ui
+++ b/src/transmageddon.ui
@@ -1,7 +1,31 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.16.1 -->
 <interface>
-  <!-- interface-requires gtk+ 3.0 -->
+  <requires lib="gtk+" version="3.0"/>
   <object class="GtkAction" id="action1"/>
+  <object class="GtkComboBox" id="combo">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="active">0</property>
+    <child>
+      <object class="GtkCellRendererText" id="cellrenderertext1"/>
+      <attributes>
+        <attribute name="text">1</attribute>
+      </attributes>
+      <cell-packing>
+        <property name="expand">True</property>
+      </cell-packing>
+    </child>
+    <child>
+      <object class="GtkCellRendererPixbuf" id="pixbuf"/>
+      <attributes>
+        <attribute name="pixbuf">0</attribute>
+      </attributes>
+      <cell-packing>
+        <property name="expand">True</property>
+      </cell-packing>
+    </child>
+  </object>
   <object class="GtkListStore" id="outputformatmodel">
     <columns>
       <!-- column-name gchararray1 -->


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]