def refresh(self, widget, notify_no_new_messages=True):
        """This method refreshes the status icon if there is new mail."""
        self.status_icon.set_tooltip(_("Checking mail accounts"))
        accounts = Account.select()
        if accounts.count() > 0:
            messages_count_tuples = []
            total_messages = 0
            for account in accounts:
                # because sqlobject automatically saves objects:
                if account.is_valid():
                    ac_total_messages = account.get_mail_count()
                    total_messages += ac_total_messages
                    messages_count_tuples.append((account, ac_total_messages))

            if total_messages:
                NotificationController.new_messages(messages_count_tuples)
                self.status_icon.set_from_file(
                    "icons/indicator-messages-new.svg")
            else:
                if notify_no_new_messages:
                    NotificationController.no_new_messages()
                self.status_icon.set_from_file("icons/indicator-messages.svg")
        else:
            NotificationController.no_accounts()
            self.status_icon.set_from_file("icons/mail-mark-important.svg")
        self.status_icon.set_tooltip(
            _("Last revision at ") + time.strftime("%H:%M:%S"))
        return True
 def no_accounts(cls):
     """This method creates a new notification for no accounts."""
     session_bus = dbus.SessionBus()
     notifications_object = session_bus.get_object(
         'org.freedesktop.Notifications', '/org/freedesktop/Notifications')
     notifications_interface = dbus.Interface(
         notifications_object, 'org.freedesktop.Notifications')
     notification_id = notifications_interface.Notify(
         "traymail", 0, "notification-message-IM", _("No accounts"),
         _("Please create a new account"), dbus.Array([], signature='s'),
         dbus.Array([], signature='(sv)'), -1)
示例#3
0
    def _init(self):
        self.list_box_files = wx.ListBox(self)
        self.sizer.Add(self.list_box_files, 1, wx.EXPAND, 0)

        self.list_ctrl_info = wx.ListCtrl(self, -1, style=wx.LC_REPORT | wx.LC_ALIGN_LEFT | wx.SUNKEN_BORDER)
        self.list_ctrl_info.InsertColumn( 0, _('Parameter'), width=400)
        self.list_ctrl_info.InsertColumn( 1, _('Value'), width=200)
        self.sizer.Add(self.list_ctrl_info, 1, wx.EXPAND, 0)

        on(events.EVENT_DATA_LOADED, self.on_data_load)
        self.list_box_files.Bind(wx.EVT_LISTBOX, self.on_select_signal)
    def __init__(self, preferences):
        """This method initializes a PreferencesController instance."""
        self.preferences = preferences
        self.builder = gtk.Builder()
        self.builder.add_from_file("glade/preferences.glade")
        self.builder.connect_signals(self)
        self.fillin_fields()

        # a little hack: internationalize this strings.
        self.builder.get_object("window1").set_title(
            _(self.builder.get_object("window1").get_title()))
        self.builder.get_object("label1").set_text(
            _(self.builder.get_object("label1").get_text()))
        self.builder.get_object("checkbutton1").set_label(
            _(self.builder.get_object("checkbutton1").get_label()))
    def create_popup_menu(self):
        """This method creates the popup menu and attachs it to the status icon."""
        self.popup_menu = gtk.Menu()

        menu_item = gtk.ImageMenuItem(gtk.STOCK_REFRESH)
        menu_item.connect("activate", self.refresh)
        self.popup_menu.append(menu_item)

        menu_item = gtk.SeparatorMenuItem()
        self.popup_menu.append(menu_item)

        menu_item = gtk.MenuItem(_("Accounts"))
        menu_item.connect("activate", self.open_accounts)
        self.popup_menu.append(menu_item)

        menu_item = gtk.ImageMenuItem(gtk.STOCK_PREFERENCES)
        menu_item.connect("activate", self.open_preferences)
        self.popup_menu.append(menu_item)

        menu_item = gtk.SeparatorMenuItem()
        self.popup_menu.append(menu_item)

        menu_item = gtk.ImageMenuItem(gtk.STOCK_ABOUT)
        menu_item.connect("activate", self.open_about_dialog)
        self.popup_menu.append(menu_item)

        menu_item = gtk.ImageMenuItem(gtk.STOCK_QUIT)
        menu_item.connect("activate", self.destroy)
        self.popup_menu.append(menu_item)
示例#6
0
文件: data.py 项目: miphreal/dsp
    def __init__(self, file_name=None):
        self.file_name = file_name

        if self.file_name:
            with open(self.file_name, 'rb') as f:
                self.data = f.read()

            header = Struct(HEADER_DATA_FORMAT)
            self.header = SignalHeader(*header.unpack(self.data[:header.size]))
            self.raw_signal = self.data[header.size:]

            self.float_data = [unpack('f', self.raw_signal[i:i+4])[0] for i in xrange(0, len(self.raw_signal)-4, 4)]

            logger.info(_('File is loaded: %s') % file_name)
            logger.info(_('File info: %s') % repr(self.header))
            progress_tick()
示例#7
0
文件: progress.py 项目: miphreal/dsp
 def __init__(self, parent=None, conf=app_config):
     self.parent = parent
     self.conf = conf
     super(ProgressWindow, self).__init__(parent, -1, _('Progress'), size=self.SIZE,
         style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_NO_TASKBAR|wx.FRAME_NO_WINDOW_MENU|wx.BORDER_NONE)
     self.create_progress()
     self.conf.on(events.EVENT_CHANGED_PARAMETER_key('main_progress_*'), self.evt_on_change_config_parameter)
示例#8
0
    def _create_color_props(self):
        self.colour_box = wx.StaticBox(self, label=_('Colours'))
        self.colour_box_sizer = wx.StaticBoxSizer(self.colour_box)

        self.colour_box_sizer.Add(wx.StaticText(self, label=_('Background Color:')), 0, wx.ALIGN_CENTER_VERTICAL)
        self.button_facecolor = wx.ColourPickerCtrl(self, col=self.conf.draw_facecolor)
        self.colour_box_sizer.Add(self.button_facecolor, 0, wx.ALIGN_CENTER_VERTICAL)
        self.colour_box_sizer.AddSpacer(20)

        self.colour_box_sizer.Add(wx.StaticText(self, label=_('Static Cursor Color:')), 0, wx.ALIGN_CENTER_VERTICAL)
        self.button_static_cursor_color = wx.ColourPickerCtrl(self, col=self.conf.draw_static_cursor_color)
        self.colour_box_sizer.Add(self.button_static_cursor_color, 0, wx.ALIGN_CENTER_VERTICAL)
        self.colour_box_sizer.AddSpacer(20)

        self.colour_box_sizer.Add(wx.StaticText(self, label=_('Dynamic Cursor Color:')), 0, wx.ALIGN_CENTER_VERTICAL)
        self.button_dynamic_cursor_color = wx.ColourPickerCtrl(self, col=self.conf.draw_dynamic_cursor_color)
        self.colour_box_sizer.Add(self.button_dynamic_cursor_color, 0, wx.ALIGN_CENTER_VERTICAL)

        self.sizer.Add(self.colour_box_sizer, 0, wx.EXPAND)
示例#9
0
    def create_treeview(self):
        """This method creates the account treeview."""
        treeview = self.builder.get_object("treeview1")

        liststore = gtk.ListStore(str, str)

        column = gtk.TreeViewColumn(_("Name"))
        cell = gtk.CellRendererText()
        column.pack_start(cell, True)
        column.add_attribute(cell, 'text', 0)
        treeview.append_column(column)

        column = gtk.TreeViewColumn(_("Protocol"))
        cell = gtk.CellRendererText()
        column.pack_start(cell, True)
        column.add_attribute(cell, 'text', 1)
        treeview.append_column(column)

        treeview.set_model(liststore)
示例#10
0
    def __init__(self):
        """This method initializes an AccountsController instance."""
        self.builder = gtk.Builder()
        self.builder.add_from_file("glade/accounts.glade")
        self.builder.connect_signals(self)

        # a little hack: internationalize this string.
        self.builder.get_object("window1").set_title(
            _(self.builder.get_object("window1").get_title()))

        self.create_treeview()
        self.populate_treeview()
示例#11
0
 def delete_account(self, widget):
     """This method deletes de selected account, asking for a confirmation."""
     m_dialog = gtk.MessageDialog(None, 0, gtk.MESSAGE_QUESTION,
                                  gtk.BUTTONS_YES_NO, _("Are you sure?"))
     if m_dialog.run() == gtk.RESPONSE_YES:
         treeview = self.builder.get_object("treeview1")
         ac_name = treeview.get_model().get_value(
             treeview.get_selection().get_selected()[1], 0)
         account = Account.select(Account.q.name == ac_name).getOne()
         account.destroySelf()
         self.update(None)
     m_dialog.destroy()
     self.set_insensitive_buttons()
 def new_messages(cls, messages_count_tuples):
     """This method creates a new notification for new messages."""
     total_messages = 0
     message_body = ""
     for account, ac_total_messages in messages_count_tuples:
         if ac_total_messages > 0:
             total_messages += ac_total_messages
             if ac_total_messages == 1:
                 message_body += _(
                     "%(ac_total_messages)d new message at %(ac_name)s\n"
                 ) % {
                     'ac_total_messages': ac_total_messages,
                     'ac_name': account.name
                 }
             else:
                 message_body += _(
                     "%(ac_total_messages)d new messages at %(ac_name)s\n"
                 ) % {
                     'ac_total_messages': ac_total_messages,
                     'ac_name': account.name
                 }
             if ac_total_messages and account.custom_command:
                 # append an & for a command that can run indefinitely
                 os.system(account.custom_command + "&")
     message_body = message_body[0:len(message_body) - 1]
     if total_messages == 1:
         message_title = _("1 new message")
     else:
         message_title = _("%d new messages") % (total_messages)
     session_bus = dbus.SessionBus()
     notifications_object = session_bus.get_object(
         'org.freedesktop.Notifications', '/org/freedesktop/Notifications')
     notifications_interface = dbus.Interface(
         notifications_object, 'org.freedesktop.Notifications')
     notification_id = notifications_interface.Notify(
         "traymail", 0, "notification-message-email", message_title,
         message_body, dbus.Array([], signature='s'),
         dbus.Array([], signature='(sv)'), -1)
示例#13
0
文件: data.py 项目: miphreal/dsp
def data_factory(file_name):
    files = []
    if file_name.endswith(DATA_FILE_TYPE):
        files.append(file_name)
    elif file_name.endswith(DATA_GROUP_TYPE):
        with open(file_name) as group:
            for line in group:
                line = line.strip()
                if line.endswith(DATA_FILE_TYPE) and not os.path.isabs(line):
                    line = os.path.join(os.path.dirname(file_name), line)
                if not os.path.exists(line):
                    logger.error(_('File does not exist: %s') % line)
                    continue
                files.append(line)

    return SignalsDataSet(files=files)
示例#14
0
文件: data.py 项目: miphreal/dsp
import copy
import os
from collections import namedtuple
from struct import Struct, unpack

from lib.log import get_logger
from lib.i18n import gettext as _
from ui.frames.progress import progress_tick, progress_new, progress_release


logger = get_logger('dsp.data')

DATA_FILE_TYPE = '.bin'
DATA_GROUP_TYPE = '.txt'
SOURCE_DATA_TYPES = {
    '*.bin': _('Channel Data Source (*.bin)'),
    '*.txt': _('Channels Source Bundle (*.txt)'),
    }
SOURCE_DATA_TYPES_LINE = '|'.join('%s|%s' % (hint, ext) for ext, hint in SOURCE_DATA_TYPES.items())

HEADER_DATA_FORMAT = (
    '4s'    # сигнатура файла TMB1
    'I'     # Количество каналов: 4 байта, целое (Количество каналов по которым принимался сигнал)
    'I'     # Размер выборки на один канал: 4 байта, целое (число дискретных точек на один временной интервал приема данных (блок даных) N)
    'I'     # Количество спектральных линий: 4 байта, целое (меньше или равно N/2)
    'I'     # Частота среза: 4 байта, целое  (заданная частота среза ФНЧ при приеме данных)
    'f'     # Частотное разрешение: 4 байта, вещественное (шаг по частоте между спектральными линиями при анализе, Гц )
    'f'     # Время приёма блока данных: 4 байта, вещественное (время за которое принимался  блок данных, величина обратная частотному разрешению)
    'I'     # Общее время приёма данных: 4 байта, целое  (время приема всей реализации в секундах)
    'I'     # Количество принятых блоков (задано пользователем): 4 байта, целое (то что было задано пользователем при приеме данных)
    'I'     # размер данных: 4 байта, целое (количество дискретных отсчетов в файле даных)
示例#15
0
if hasattr(sys, 'gettrace') and sys.gettrace():
    extension.affect(args=remaining_args)
else:
    save_stderr()
    exception = None
    try:
        extension.affect(args=remaining_args)
    except (SystemExit, KeyboardInterrupt):
        raise
    except Exception:
        exception = traceback.format_exc()
    finally:
        restore_stderr()

        if shapely_errors.tell():
            print >> sys.stderr, shapely_errors.getvalue()

    if exception:
        print >> sys.stderr, _(
            "Ink/Stitch experienced an unexpected error.").encode("UTF-8")
        print >> sys.stderr, _(
            "If you'd like to help, please file an issue at "
            "https://github.com/inkstitch/inkstitch/issues "
            "and include the entire error description below:").encode(
                "UTF-8"), "\n"
        print >> sys.stderr, exception
        sys.exit(1)
    else:
        sys.exit(0)
示例#16
0
extension_class_name = extension_name.title().replace("_", "")

extension_class = getattr(extensions, extension_class_name)
extension = extension_class()

if hasattr(sys, 'gettrace') and sys.gettrace():
    extension.run(args=remaining_args)
else:
    save_stderr()
    exception = None
    try:
        extension.run(args=remaining_args)
    except (SystemExit, KeyboardInterrupt):
        raise
    except XMLSyntaxError:
        msg = _("Ink/Stitch cannot read your SVG file. "
                "This is often the case when you use a file which has been created with Adobe Illustrator.")
        msg += "\n\n"
        msg += _("Try to import the file into Inkscape through 'File > Import...' (Ctrl+I)")
        errormsg(msg)
    except Exception:
        exception = traceback.format_exc()
    finally:
        restore_stderr()

        if shapely_errors.tell():
            errormsg(shapely_errors.getvalue())

    if exception:
        errormsg(_("Ink/Stitch experienced an unexpected error.") + "\n")
        errormsg(_("If you'd like to help, please file an issue at "
                   "https://github.com/inkstitch/inkstitch/issues "
示例#17
0
 def _show_signal_info(self, signal_id=0):
     self.list_ctrl_info.DeleteAllItems()
     data = self.data[signal_id]
     for field in data.header._fields:
         self._insert_entry(_(field), unicode(getattr(data.header, field)))
 def create_status_icon(self):
     """This method creates the status icon."""
     self.status_icon = gtk.StatusIcon()
     self.status_icon.set_from_file("icons/indicator-messages.svg")
     self.status_icon.set_tooltip(_("Check your mail in the systray"))