Internet radio browser GUI for music/video streams from various directory services.

⌈⌋ ⎇ branch:  streamtuner2


Diff

Differences From Artifact [a65b5708f4]:

To Artifact [95ed169041]:


181
182
183
184
185
186
187


188
189
190
191
192
193
194
                "menu_toolbar_size_small": lambda w: (self.toolbar.set_icon_size(gtk.ICON_SIZE_SMALL_TOOLBAR)),
                "menu_toolbar_size_medium": lambda w: (self.toolbar.set_icon_size(gtk.ICON_SIZE_DND)),
                "menu_toolbar_size_large": lambda w: (self.toolbar.set_icon_size(gtk.ICON_SIZE_DIALOG)),
                # else
                "menu_properties": config_dialog.open,
                "config_cancel": config_dialog.hide,
                "config_save": config_dialog.save,


                "update_categories": self.update_categories,
                "update_favicons": self.update_favicons,
                "app_state": self.app_state,
                "bookmark": self.bookmark,
                "save_as": self.save_as,
                "menu_about": lambda w: AboutStreamtuner2(),
                "menu_help": action.action.help,







>
>







181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
                "menu_toolbar_size_small": lambda w: (self.toolbar.set_icon_size(gtk.ICON_SIZE_SMALL_TOOLBAR)),
                "menu_toolbar_size_medium": lambda w: (self.toolbar.set_icon_size(gtk.ICON_SIZE_DND)),
                "menu_toolbar_size_large": lambda w: (self.toolbar.set_icon_size(gtk.ICON_SIZE_DIALOG)),
                # else
                "menu_properties": config_dialog.open,
                "config_cancel": config_dialog.hide,
                "config_save": config_dialog.save,
                "config_player_edited": config_dialog.edited_player_row,
                "config_player_edited_2": config_dialog.edited_player_row_2,
                "update_categories": self.update_categories,
                "update_favicons": self.update_favicons,
                "app_state": self.app_state,
                "bookmark": self.bookmark,
                "save_as": self.save_as,
                "menu_about": lambda w: AboutStreamtuner2(),
                "menu_help": action.action.help,
743
744
745
746
747
748
749
750
751
752
753
754
755
756

757
758
759
760
761
762
763
764
765
766
767
768
769
770
771













772
773


774
775

776
777
778

779
780


781
782

783


784
785





786
787
788
789
790
791
792



# aux win: settings UI
class config_dialog (auxiliary_window):


        # display win_config, pre-fill text fields from global conf. object
        def open(self, widget):
            if self.first_open:
                self.add_plugins()
                self.combobox_theme()
                self.first_open = 0
            self.apply(conf.__dict__, "config_", 0)

            self.win_config.show()
        first_open = 1


        def hide(self, *args):
            self.win_config.hide()
            return True

        
        # set/load values between gtk window and conf. dict
        def apply(self, config, prefix="config_", save=0):
            for key,val in config.items():
                # map non-alphanumeric chars from config{} to underscores in according gtk widget names
                id = re.sub("[^\w]", "_", key)
                w = main.get_widget(prefix + id)













                __print__(dbg.CONF, "config", ("save" if save else "load"), prefix+id, w, val)
                # recurse into dictionaries, transform: conf.play.audio/mpeg => conf.play_audio_mpeg


                if (type(val) == dict):
                    self.apply(val, prefix + id + "_", save)

                # load or set gtk.Entry text field
                elif (w and save and type(w)==gtk.Entry):
                    config[key] = w.get_text()

                elif (w and type(w)==gtk.Entry):
                    w.set_text(str(val))


                elif (w and save):
                    config[key] = w.get_active()

                elif (w):


                    w.set_active(bool(val))
            pass







        # fill combobox
        def combobox_theme(self):
           # self.theme.combo_box_new_text()
            # find themes
            themedirs = (conf.share+"/themes", conf.dir+"/themes", "/usr/share/themes")







|





|
>



|





|
|

<
<
|
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
>
>
|
|
>
|
|
|
>
|
<
>
>
|
|
>
|
>
>
|
|
>
>
>
>
>







745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771


772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797

798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819



# aux win: settings UI
class config_dialog (auxiliary_window):


        # Display win_config, pre-fill text fields from global conf. object
        def open(self, widget):
            if self.first_open:
                self.add_plugins()
                self.combobox_theme()
                self.first_open = 0
            self.load_config(conf.__dict__, "config_")
            self.load_config(conf.plugins, "config_plugins_")
            self.win_config.show()
        first_open = 1

        # Hide window
        def hide(self, *args):
            self.win_config.hide()
            return True

        
        # Load values from conf. store into gtk widgets
        def load_config(self, config, prefix="config_"):
            for key,val in config.items():


                w = main.get_widget(prefix + key)
                if w:
                    # input field
                    if type(w) is gtk.Entry:
                        w.set_text(str(val))
                    # checkmark
                    elif type(w) is gtk.CheckButton:
                        w.set_active(bool(val))
                    # list
                    elif type(w) is gtk.ListStore:
                        w.clear()
                        for k,v in val.items():
                            w.append([k, v, True])
                        w.append(["", "", True])
                __print__(dbg.CONF, "config load", prefix+key, val, type(w))

        # Store gtk widget valus back into conf. dict
        def save_config(self, config, prefix="config_", save=0):
            for key,val in config.items():
                w = main.get_widget(prefix + key)
                if w:
                    # text
                    if type(w) is gtk.Entry:
                        config[key] = w.get_text()
                    # boolean
                    elif type(w) is gtk.CheckButton:

                        config[key] = w.get_active()
                    # dict
                    elif type(w) is gtk.ListStore:
                        config[key] = {}
                        for row in w:
                            if row[0] and row[1]:
                                config[key][row[0]] = row[1]
                __print__(dbg.CONF, "config save", prefix+key, val)

        
        # Gtk callback to update ListStore when entries get edited
        def edited_player_row(self, cell, path, new_text, user_data=None, column=0):
            main.config_play[path][column] = new_text
        def edited_player_row_2(self, cell, path, new_text, user_data=None):
            self.edited_player_row(cell, path, new_text, column=1)


        # fill combobox
        def combobox_theme(self):
           # self.theme.combo_box_new_text()
            # find themes
            themedirs = (conf.share+"/themes", conf.dir+"/themes", "/usr/share/themes")
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858

859
860
861
862
863
864
865

866
867
868
869
870
871
872
873
874
875
876

877
878
879
880
881
882
883
                        else:
                            self.add_( "config_"+opt["name"], gtk.Entry(), opt["description"] )

                # spacer 
                self.add_( "filler_pl_"+name, gtk.HSeparator() )


        # put gtk widgets into config dialog notebook
        def add_(self, id, w, label=None, color=""):
            w.set_property("visible", True)
            main.widgets[id] = w
            if label:
                w.set_width_chars(11)
                w = self.hbox(w, self.label(label))
            if color:
                w = mygtk.bg(w, color)
            self.plugin_options.pack_start(w)


        def label(self, label):
            label = gtk.Label(label)
            label.set_property("visible", True)
            label.set_line_wrap(True) 
            label.set_size_request(400, -1)
            return label


        def hbox(self, w1, w2):
            vbox = gtk.HBox(homogeneous=False, spacing=10)
            vbox.set_property("visible", True)
            vbox.pack_start(w1, expand=False, fill=False)
            vbox.pack_start(w2, expand=True, fill=True)
            return vbox

        
        # save config
        def save(self, widget):
            self.apply(conf.__dict__, "config_", 1)

            self.apply_theme()
            conf.save(nice=1)
            self.hide()
                  
config_dialog = config_dialog()
# instantiates itself








|










>







>










|
>







868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
                        else:
                            self.add_( "config_"+opt["name"], gtk.Entry(), opt["description"] )

                # spacer 
                self.add_( "filler_pl_"+name, gtk.HSeparator() )


        # Put config widgets into config dialog notebook
        def add_(self, id, w, label=None, color=""):
            w.set_property("visible", True)
            main.widgets[id] = w
            if label:
                w.set_width_chars(11)
                w = self.hbox(w, self.label(label))
            if color:
                w = mygtk.bg(w, color)
            self.plugin_options.pack_start(w)

        # Create GtkLabel
        def label(self, label):
            label = gtk.Label(label)
            label.set_property("visible", True)
            label.set_line_wrap(True) 
            label.set_size_request(400, -1)
            return label

        # Wrap two widgets in vertical box
        def hbox(self, w1, w2):
            vbox = gtk.HBox(homogeneous=False, spacing=10)
            vbox.set_property("visible", True)
            vbox.pack_start(w1, expand=False, fill=False)
            vbox.pack_start(w2, expand=True, fill=True)
            return vbox

        
        # save config
        def save(self, widget):
            self.save_config(conf.__dict__, "config_")
            self.save_config(conf.plugins, "config_plugins_")
            self.apply_theme()
            conf.save(nice=1)
            self.hide()
                  
config_dialog = config_dialog()
# instantiates itself