Exemplo n.º 1
0
 def export_sched(cls, *args):
     'Export a single schedule with belonging presentations to file.'
     sched = exposong.schedlist.schedlist.get_active_item()
     if not sched:
         return False
     dlg = gtk.FileChooserDialog(_("Export Current Schedule"),
                                 exposong.main.main,
                                 gtk.FILE_CHOOSER_ACTION_SAVE,
                                 (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                                 gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
     dlg.add_filter(_FILTER)
     dlg.set_do_overwrite_confirmation(True)
     dlg.set_current_folder(config.get("open-save-dialogs", "export-sched"))
     dlg.set_current_name(os.path.basename(title_to_filename(sched.title))+".expo")
     if dlg.run() == gtk.RESPONSE_ACCEPT:
         os.chdir(DATA_PATH)
         fname = dlg.get_filename()
         if not fname.endswith(".expo"):
             fname += ".expo"
         exposong.log.info('Exporting schedule "%s" to "%s".',
                           sched.title, fname)
         tar = tarfile.open(fname, "w:gz")
         for item in cls._get_sched_list():
             tar.add(item[0], item[1])
         tar.close()
         config.set("open-save-dialogs", "export-sched", os.path.dirname(fname))
     dlg.destroy()
Exemplo n.º 2
0
 def _load_themes(self):
     "Load all the themes from disk."
     exposong.log.debug("Loading theme previews.")
     try:
         active = config.get("screen", "theme")
     except Exception:
         active = None
     
     name = '_builtin_black'
     bltheme = exposong.theme.Theme(builtin=True)
     bltheme.meta['title'] = _('Black')
     
     itr = self.liststore.append([name, bltheme])
     self.set_active_iter(itr)
     yield True
     
     dir = os.path.join(DATA_PATH, "theme")
     for filenm in os.listdir(dir):
         if not filenm.endswith('.xml'):
             continue
         if not os.path.isfile(os.path.join(dir, filenm)):
             continue
         path = os.path.join(dir, filenm)
         exposong.log.info('Loading theme "%s".',
                           filenm)
         theme = exposong.theme.Theme(path)
         itr = self.liststore.append([path, theme])
         if path == active:
             self.set_active_iter(itr)
         yield True
     task = self._load_theme_thumbs()
     gobject.idle_add(task.next, priority=gobject.PRIORITY_LOW)
     yield True
     self.liststore.set_sort_column_id(1, gtk.SORT_ASCENDING)
     yield False
Exemplo n.º 3
0
 def export_theme(cls, *args):
     'Export the active theme to tar-compressed file'
     cur_theme = exposong.themeselect.themeselect.get_active()
     
     dlg = gtk.FileChooserDialog(_("Export Theme"), exposong.main.main,
                                 gtk.FILE_CHOOSER_ACTION_SAVE,
                                 (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                                 gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
     dlg.add_filter(_FILTER)
     dlg.set_do_overwrite_confirmation(True)
     dlg.set_current_folder(config.get("open-save-dialogs", "export-theme"))
     dlg.set_current_name(_("theme_%s.expo")%title_to_filename(
                                     os.path.basename(cur_theme.get_title())))
     if dlg.run() == gtk.RESPONSE_ACCEPT:
         fname = dlg.get_filename()
         if not fname.endswith(".expo"):
             fname += ".expo"
         exposong.log.info('Exporting theme "%s" to "%s".',
                           cur_theme.get_title(), fname)
         tar = tarfile.open(fname, "w:gz")
         
         tar.add(os.path.join(DATA_PATH, 'theme', cur_theme.filename),
                 os.path.join('theme', cur_theme.filename))
         for bg in cur_theme.backgrounds:
             if isinstance(bg, exposong.theme.ImageBackground):
                 tar.add(os.path.join(DATA_PATH, 'theme', 'res', bg.src),
                         os.path.join('theme', 'res', bg.src))
         tar.close()
         config.set("open-save-dialogs", "export-theme", os.path.dirname(fname))
     dlg.destroy()
Exemplo n.º 4
0
 def import_song_dialog(cls, *args):
     'Import OpenLyrics Song(s)'
     dlg = gtk.FileChooserDialog(_("Import Song(s) (OpenLyrics Format)"), exposong.main.main,
                                 gtk.FILE_CHOOSER_ACTION_OPEN,
                                 (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                                 gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
     _FILTER = gtk.FileFilter()
     _FILTER.set_name("OpenLyrics Song")
     _FILTER.add_pattern("*.xml")
     dlg.add_filter(_FILTER)
     dlg.set_select_multiple(True)
     dlg.set_current_folder(config.get("open-save-dialogs", "import-song"))
     if dlg.run() == gtk.RESPONSE_ACCEPT:
         dlg.hide()
         files = dlg.get_filenames()
         for f in files:
             newpath = os.path.join(DATA_PATH, "pres", os.path.basename(f))
             if os.path.exists(newpath):
                 if filecmp.cmp(f, newpath):
                     pass #Skip if they are the same.
                 else:
                     cls.check_import_song(f)
             else:
                 cls.check_import_song(f)
         config.set("open-save-dialogs", "import-song", os.path.dirname(f))
     dlg.destroy()
Exemplo n.º 5
0
 def import_dialog(cls, *args):
     'Import a schedule, backgrounds or library.'
     dlg = gtk.FileChooserDialog(_("Import"), exposong.main.main,
                                 gtk.FILE_CHOOSER_ACTION_OPEN,
                                 (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                                 gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
     dlg.add_filter(_FILTER)
     dlg.set_current_folder(config.get("open-save-dialogs", "import-expo"))
     if dlg.run() == gtk.RESPONSE_ACCEPT:
         dlg.hide()
         cls.import_file(dlg.get_filename())
         config.set("open-save-dialogs", "import-expo", os.path.dirname(dlg.get_filename()))
     dlg.destroy()
Exemplo n.º 6
0
 def to_logo(self, action=None):
     'Set the screen to the ExpoSong logo or a user-defined one.'
     if action == None:
         action = self._actions.get_action('Logo')
     if not action.get_active():
         self._secondary_button_toggle(action)
         return
     if config.has_option("screen", "logo") and \
             os.path.isfile(config.get("screen", "logo")):
         # TODO should we resize the logo? If not, we need to add the
         # feature to theme.Image
         try:
             if self.__logo_fl != config.get("screen", "logo"):
                 self.__logo_fl = config.get('screen', 'logo')
                 self.__logo_img = exposong.theme.Image(self.__logo_fl,
                         pos=[0.2, 0.2, 0.8, 0.8])
         except AttributeError:
             self.__logo_fl = config.get('screen', 'logo')
             self.__logo_img = exposong.theme.Image(self.__logo_fl,
                     pos=[0.2, 0.2, 0.8, 0.8])
         self._secondary_button_toggle(action, True)
     else:
         self._secondary_button_toggle(None)
         msg = _('No Logo set. Do you want to choose a Logo now?')
         dialog = gtk.MessageDialog(exposong.main.main, gtk.DIALOG_MODAL,
                                    gtk.MESSAGE_WARNING, gtk.BUTTONS_YES_NO,
                                    msg)
         dialog.set_default_response(gtk.RESPONSE_YES)
         dialog.set_title( _("Set Logo?") )
         resp = dialog.run()
         dialog.destroy()
         if resp == gtk.RESPONSE_YES:
             exposong.prefs.PrefsDialog(exposong.main.main)
             if os.path.isfile(config.get("screen", "logo")):
                 self.to_logo()
         else:
             self.to_background()
Exemplo n.º 7
0
 def import_dialog(cls, action):
     'Show the file dialog for importing OpenSong files'
     dlg = gtk.FileChooserDialog(_("Import OpenSong File(s)"),
             exposong.main.main, gtk.FILE_CHOOSER_ACTION_OPEN,
             (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK,
             gtk.RESPONSE_ACCEPT))
     dlg.set_select_multiple(True)
     dlg.set_current_folder(config.get("open-save-dialogs", "opensong-import-dir"))
     if dlg.run() == gtk.RESPONSE_ACCEPT:
         dlg.hide()
         files = dlg.get_filenames()
         for f in files:
             filename = cls.convert(unicode(f))
             exposong.main.main.load_pres(filename)
         config.set("open-save-dialogs", "opensong-import-dir", os.path.dirname(f))
     dlg.destroy()
Exemplo n.º 8
0
 def export_lib(cls, *args):
     'Export the full library to tar-compressed file.'
     dlg = gtk.FileChooserDialog(_("Export Library"), exposong.main.main,
                                 gtk.FILE_CHOOSER_ACTION_SAVE,
                                 (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                                 gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
     dlg.add_filter(_FILTER)
     dlg.set_do_overwrite_confirmation(True)
     dlg.set_current_name(_("exposong_library.expo"))
     dlg.set_current_folder(config.get("open-save-dialogs", "export-lib"))
     if dlg.run() == gtk.RESPONSE_ACCEPT:
         fname = dlg.get_filename()
         if not fname.endswith(".expo"):
             fname += ".expo"
         exposong.log.info('Exporting library to "%s".', fname)
         tar = tarfile.open(fname, "w:gz")
         for item in cls._get_library_list():
             tar.add(item[0], item[1])
         tar.close()
         config.set("open-save-dialogs", "export-lib", os.path.dirname(fname))
     dlg.destroy()
Exemplo n.º 9
0
 def import_dialog(cls, action):
     "Show the file dialog for importing SongSelect Lyrics"
     dlg = gtk.FileChooserDialog(_("Import SongSelect Lyrics"),
                                 exposong.main.main,
                                 gtk.FILE_CHOOSER_ACTION_OPEN,
                                 (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                                 gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
     dlg.set_select_multiple(True)
     filter_ = gtk.FileFilter()
     filter_.set_name(_("SongSelect File (%s)") % ".usr")
     filter_.add_pattern("*.usr")
     dlg.add_filter(filter_)
     dlg.set_current_folder(config.get("open-save-dialogs", "songselect-import-dir"))
     if dlg.run() == gtk.RESPONSE_ACCEPT:
         dlg.hide()
         files = dlg.get_filenames()
         for f in files:
             filename = cls.convert(unicode(f), True)
             exposong.main.main.load_pres(filename)
         config.set("open-save-dialogs", "songselect-import-dir", os.path.dirname(f))
     dlg.destroy()
Exemplo n.º 10
0
 def reposition(self, parent):
     '''
     Finds the best location for the screen.
     
     If the user is using one monitor, use the bottom right corner for
     the presentation screen_, otherwise, use the 2nd monitor.
     '''
     geometry = None
     screen_ = parent.get_screen()
     num_monitors = screen_.get_n_monitors()
     
     if config.has_option('screen','monitor'):
         if config.get('screen', 'monitor') == '1h':
             scr_geom = screen_.get_monitor_geometry(0)
             geometry = (scr_geom.width/2, scr_geom.height/2,
                         scr_geom.width/2, scr_geom.height/2)
         elif num_monitors >= config.getint('screen','monitor'):
             scr_geom = screen_.get_monitor_geometry(
                                     config.getint('screen','monitor')-1)
             geometry = (scr_geom.x, scr_geom.y, scr_geom.width,
                         scr_geom.height)
     
     if geometry == None:
         if(num_monitors > 1):
             scr_geom = screen_.get_monitor_geometry(1)
             geometry = (scr_geom.x, scr_geom.y, scr_geom.width,
                         scr_geom.height)
         else:
             # No 2nd monitor, so preview it small in the corner of the screen_
             scr_geom = screen_.get_monitor_geometry(0)
             parent.move(0,0)
             geometry = (scr_geom.width/2, scr_geom.height/2,
                         scr_geom.width/2, scr_geom.height/2)
     exposong.log.info('Setting presentation screen position to %s.',
                        "x=%d, y=%d, w=%d, h=%d" % geometry)
     self.window.move(geometry[0], geometry[1])
     self.window.resize(geometry[2], geometry[3])
     self.aspect = float(geometry[2])/geometry[3]
     self.preview.set_size_request(int(PREV_HEIGHT*self.aspect), PREV_HEIGHT)
     self._size = geometry[2:4]
Exemplo n.º 11
0
 def export_song(cls, *args):
     'Export a Song'
     pres = exposong.preslist.preslist.get_active_item()
     
     dlg = gtk.FileChooserDialog(_("Export Current Song"),
                                 exposong.main.main,
                                 gtk.FILE_CHOOSER_ACTION_SAVE,
                                 (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                                 gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
     dlg.set_do_overwrite_confirmation(True)
     dlg.set_current_folder(config.get("open-save-dialogs", "export-song"))
     dlg.set_current_name(os.path.basename(pres.filename))
     if dlg.run() == gtk.RESPONSE_ACCEPT:
         os.chdir(DATA_PATH)
         fname = dlg.get_filename()
         if not fname.endswith(".xml"):
             fname += ".xml"
         exposong.log.info('Exporting presentation "%s" to "%s".',
                           pres.get_title(), fname)
         shutil.copy(pres.filename, fname)
         config.set("open-save-dialogs", "export-song", os.path.dirname(fname))
     dlg.destroy()
Exemplo n.º 12
0
 def _on_bg_image_new(self, widget=None):
     'Add a new background image'
     self._set_changed()
     fchooser = gtk.FileChooserDialog( _("Add Images"), self,
             gtk.FILE_CHOOSER_ACTION_OPEN,
             (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
             gtk.STOCK_ADD, gtk.RESPONSE_ACCEPT) )
     fchooser.set_current_folder(config.get("open-save-dialogs", "themeeditor-add-bg-image"))
     filt = gtk.FileFilter()
     filt.set_name( _("Image Types") )
     filt.add_pixbuf_formats()
     fchooser.add_filter(filt)
     if fchooser.run() == gtk.RESPONSE_ACCEPT:
         fchooser.hide()
         img = fchooser.get_filename()
         newpath = os.path.join(DATA_PATH, 'theme', 'res', os.path.basename(img))
         if newpath != img:
             shutil.copy(img, newpath)
         itr = self._bg_model.append(
             (exposong.theme.ImageBackground(src=os.path.basename(img)),))
         self._activate_bg(itr)
         config.set("open-save-dialogs", "themeeditor-add-bg-image", os.path.dirname(img))
     fchooser.destroy()
     self.draw()
Exemplo n.º 13
0
    def __init__(self, parent):
        """
        Create the preferences GUI dialog.
        
        parent: the primary window that the dialog will be centered on.
        """
        gtk.Dialog.__init__(self, _("Preferences"), parent, 0,
                            (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                            gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
        self.set_default_size(350, 410)
        notebook = gtk.Notebook()
        self.vbox.pack_start(notebook, True, True, 5)
        
        #General Page
        table = gui.ESTable(10, auto_inc_y=True)
        
        if config.has_option("general", "data-path"):
            folder = config.get("general", "data-path")
        else:
            folder = DATA_PATH
        g_data = table.attach_folderchooser(folder, label=_("Data folder"))
        msg = _("The place where all your presentations, schedules and \
themes are stored.")
        g_data.set_tooltip_text(msg)
        table.attach_section_title(_("Updates"))
        g_update = table.attach_checkbutton(
            _("Automatically check for a new version"))
        if config.get("updates", "check_for_updates") == "True":
            g_update.set_active(True)
        
        table.attach_section_title(_("Songs"))
        g_title = table.attach_checkbutton(_("Insert title slide"))
        if config.get("songs", "title_slide") == "True":
            g_title.set_active(True)

        g_ccli = table.attach_entry(config.get("songs","ccli"),
                                    label=_("CCLI License #"))
        
        notebook.append_page(table, gtk.Label( _("General") ))
        
        #Screen Page
        table = gui.ESTable(9, auto_inc_y=True)
        
        table.attach_section_title(_("Logo"))
        p_logo = table.attach_filechooser(config.get("screen","logo"),
                                          label=_("Image"))
        p_logo_bg = table.attach_color(config.getcolor("screen","logo_bg"),
                                       label=_("Background"))
        
        table.attach_section_title(_("Notify"))
        p_notify_color = table.attach_color(config.getcolor("screen","notify_color"),
                                            label=_("Font Color"))
        p_notify_bg = table.attach_color(config.getcolor("screen","notify_bg"),
                                         label=_("Background"))
        
        # Monitor Selection
        monitor_name = tuple()
        sel = 0
        screen = parent.get_screen()
        num_monitors = screen.get_n_monitors()
        monitor_name = (_("Primary"), _("Primary (Bottom-Right)"),
                        _("Secondary"), _("Tertiary"), _("Monitor 4")
                        )[0:num_monitors+1]
        monitor_value = ('1', '1h', '2', '3', '4')[0:num_monitors+1]
        if num_monitors == 1:
            sel = monitor_name[1]
        else:
            sel = monitor_name[2]
        
        try:
            if config.get('screen', 'monitor') == '1':
                sel = monitor_name[0]
            if config.get('screen', 'monitor') == '1h':
                sel = monitor_name[1]
            else:
                sel = monitor_name[config.getint('screen', 'monitor')]
        except config.NoOptionError:
            pass
        except IndexError:
            pass
        
        table.attach_section_title(_("Position"))
        p_monitor = table.attach_combo(monitor_name, sel, label=_("Monitor"))
        
        notebook.append_page(table, gtk.Label(_("Screen")))
        
        self.show_all()
        if self.run() == gtk.RESPONSE_ACCEPT:
            if config.has_option("general", "data-path"):
                curpath = config.get("general", "data-path")
            else:
                curpath = DATA_PATH
            if g_data.get_current_folder() != curpath:
                config.set("general", "data-path", g_data.get_current_folder())
                msg = _("You will have to restart ExpoSong so that the new data folder will be used.")
                dlg = gtk.MessageDialog(self, gtk.DIALOG_DESTROY_WITH_PARENT,
                        gtk.MESSAGE_INFO, gtk.BUTTONS_OK, msg)
                dlg.run()
                dlg.destroy()
            
            if config.get("songs", "title_slide") != str(g_title.get_active()):
                config.set("songs", "title_slide", str(g_title.get_active()))
                exposong.slidelist.slidelist.update()
            config.set("songs", "ccli", g_ccli.get_text())
            config.set("updates", "check_for_updates", str(g_update.get_active()))
            
            if p_logo.get_filename() != None:
                config.set("screen", "logo", p_logo.get_filename())
            logoc = p_logo_bg.get_color()
            config.setcolor("screen", "logo_bg", (logoc.red, logoc.green, logoc.blue))
            ntfc = p_notify_color.get_color()
            config.setcolor("screen", "notify_color", (ntfc.red, ntfc.green, ntfc.blue))
            ntfb = p_notify_bg.get_color()
            config.setcolor("screen", "notify_bg", (ntfb.red, ntfb.green, ntfb.blue))
            
            config.set('screen','monitor', monitor_value[p_monitor.get_active()])
            exposong.screen.screen.reposition(parent)
            
            if hasattr(exposong.screen.screen,"_logo_pbuf"):
                del exposong.screen.screen._logo_pbuf
            exposong.screen.screen.draw()
        
        self.hide()