Beispiel #1
0
 def draw(self, ccontext, bounds):
     "Draw the notification to the screen if available."
     if not self._text:
         return
     layout = ccontext.create_layout()
     w,h = bounds
     layout.set_text(self._text)
     
     sz = int(h / 12.0)
     layout.set_font_description(pango.FontDescription(
                                 "Sans Bold " + str(sz)))
     while layout.get_pixel_size()[0] > w * 0.6:
         sz = int(sz * 0.89)
         layout.set_font_description(pango.FontDescription(
                                     "Sans Bold "+str(sz)))
     nbounds = layout.get_pixel_size()
     pad = sz/14.0
     ccontext.rectangle(w-nbounds[0]-pad*2,
                        h-nbounds[1]-pad*2,
                        w, h)
     col = exposong.screen.c2dec(config.getcolor("screen", "notify_bg"))
     ccontext.set_source_rgb(*col)
     ccontext.fill()
     col = exposong.screen.c2dec(config.getcolor("screen", "notify_color"))
     ccontext.set_source_rgb(*col)
     ccontext.move_to(w-nbounds[0]-pad, h-nbounds[1]-pad)
     ccontext.show_layout(layout)
Beispiel #2
0
 def _draw(self, widget):
     'Render `widget`.'
     if not widget.window or not widget.window.is_viewable():
         return False
     
     if self.pres.window and self.pres.window.get_size() != self._size:
         exposong.log.error('The screen sizes are inconsistent. '
                            + 'Screen: "%s"; Stored: "%s".',
                            self.pres.window.get_size(), self._size)
         self._size = self.pres.window.get_size()
     
     ccontext = widget.window.cairo_create()
     bounds = widget.window.get_size()
     if widget is self.preview:
         if self.pres.window:
             #Scale if the presentation window size is available
             bounds = self.pres.window.get_size()
         elif self._size:
             bounds = self._size
         if bounds:
             width = int(float(PREV_HEIGHT)*bounds[0]/bounds[1])
             ccontext.scale(float(width)/bounds[0],
                            float(PREV_HEIGHT)/bounds[1])
     elif widget is self.pres:
         self.preview.queue_draw()
     
     slide = exposong.slidelist.slidelist.get_active_item()
     theme = None
     
     if slide:
         theme = slide.get_theme()
     if theme is None:
         theme = exposong.themeselect.themeselect.get_active()
     if theme is None:
         # Select the first theme if nothing is set as the default.
         exposong.themeselect.themeselect.set_active(0)
         theme = exposong.themeselect.themeselect.get_active()
     
     if widget is self.pres:
         if self._actions.get_action('Black Screen').get_active():
             exposong.theme.Theme.render_color(ccontext, bounds, '#000')
         elif self._actions.get_action('Logo').get_active():
             logoclr = gtk.gdk.Color(*config.getcolor('screen', 'logo_bg'))
             exposong.theme.Theme.render_color(ccontext, bounds, logoclr.to_string())
             self.__logo_img.draw(ccontext, bounds, None)
         elif self._actions.get_action('Background').get_active():
             theme.render(ccontext, bounds, None)
         else:
             theme.render(ccontext, bounds, slide)
     
     # In Preview show the themes defined in __init__ when
     # one of the secondary buttons is active.
     if widget is self.preview:
         if self._actions.get_action('Black Screen').get_active():
             self._theme_black.render(ccontext, bounds, None)
         elif self._actions.get_action('Background').get_active():
             self._theme_bg.render(ccontext, bounds, None)
         elif self._actions.get_action('Logo').get_active():
             self._theme_logo.render(ccontext, bounds, None)
         elif self._actions.get_action('Freeze').get_active():
             self._theme_freeze.render(ccontext, bounds, None)
         else:
             theme.render(ccontext, bounds, slide)
     
     exposong.notify.notify.draw(ccontext, bounds)
         
     return True
Beispiel #3
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()