コード例 #1
0
    def __init__(self, options):

        # Verify if Lock File exist and if there is another instance running
        if not lock():
            lockfd = open(common.DAEMON_LOCK_FILE, 'r')
            lockpid = int(lockfd.readline())
            lockfd.close()
            if verify_pid(lockpid):
                print _('Lock File found:' \
                        ' You have another instance running. (pid=%d)') % \
                        lockpid
                raise SystemExit
            else:
                print _('Lock File found: ' \
                        'Possibly the program was exited unexpectedly.')
                try:
                    print _('Removing Lock File...')
                    os.remove(common.DAEMON_LOCK_FILE)
                    print _('Successfully.')
                except OSError:
                    print _('Failed.')

        # Verify if there is another Billreminder-Daemon DBus Service
        if verify_service(common.DBUS_INTERFACE):
            print _('BillReminder Notifier is already running.')
            raise SystemExit

        Daemon.__init__(self, options)

        self.client_pid = None

        self.actions = Actions()
        self.dbus_server = Server(self)
        if options.app_opengui:
            gui = Popen('billreminder', shell=True)
            self.client_pid = gui.pid
        self.alarm = Alarm(self)

        # Create the mainloop
        self.mainloop = gobject.MainLoop()
        self.mainloop.run()
コード例 #2
0
    def _get_category(self):
        """ Extracts information typed into comboboxentry """

        actions = Actions()

        if self.category.get_active_iter() is not None:
            model = self.category.get_model()
            iteration = self.category.get_active_iter()
            if iteration:
                name = model.get_value(iteration, 1)
        else:
            name = None

        if not name or name == _("None"):
            return None

        records = actions.get_categories(name=name)
        if records:
            return records[0]
        else:
            return None
コード例 #3
0
    def _populate_payee(self):
        """ Populates combobox with existing payees """
        # Connects to the database
        actions = Actions()

        # List of payees from database
        payees = []
        records = actions.get_bills()
        for rec in records:
            if rec.payee not in payees:
                payees.append(rec.payee)

        store = gtk.ListStore(gobject.TYPE_STRING)
        for payee in payees:
            store.append([payee])

        self.payee.set_model(store)
        self.payeecompletion.set_model(store)
        self.payee.set_text_column(0)
        self.payeecompletion.set_text_column(0)
        self.payeeEntry = self.payee.child
        self.selectedText = ''
コード例 #4
0
    def __init__(self):
        gobject.GObject.__init__(self)

        if exists(join(USER_CFG_PATH, CFG_NAME)):
            from lib.migrate_to_gconf import migrate
            migrate(join(USER_CFG_PATH, CFG_NAME))

        self.gconf_client = Configuration()
        self.message = Message()
        # Connects to the database
        self.actions = Actions()

        self.ui = gtk.Builder()
        self.ui.add_from_file(os.path.join(DEFAULT_CFG_PATH, "main.ui"))

        self.window = self.ui.get_object("main_window")
        self.window.set_title("%s" % common.APPNAME)
        self.window.set_icon_from_file(common.APP_ICON)

        # ViewBill
        self.list = ViewBill()
        self.list.connect('cursor_changed', self._on_list_cursor_changed)
        self.list.connect('row_activated', self._on_list_row_activated)
        self.list.connect('button_press_event',
                          self._on_list_button_press_event)

        self.ui.get_object("bill_box").add(self.list)

        # Toolbar
        self.toolbar = self.ui.get_object("toolbar")

        # Menubar
        self._populate_menubar()

        # Statusbar
        self.statusbar = Statusbar()
        self.ui.get_object("statusbar_box").add(self.statusbar)

        # Restore timeline zoom
        timeline_count = self.gconf_client.get('timeline_count')

        # Timeline
        self.timeline = Timeline(count=timeline_count,
                                 callback=self.on_timeline_cb)
        self.timeline.connect("value-changed", self._on_timeline_changed)
        self.timeline.connect("cleared", self._on_timeline_cleared)
        self.ui.get_object("timeline_box").add(self.timeline)

        # Chart
        self.chart = ChartWidget()
        self.chart.set_border_width(10)
        self.ui.get_object("chart_box").add(self.chart)

        # Restore position and size of window
        width = self.gconf_client.get('window_width')
        height = self.gconf_client.get('window_height')
        x = self.gconf_client.get('window_position_x')
        y = self.gconf_client.get('window_position_y')
        if width and height:
            self.window.resize(width, height)
        if x and y:
            self.window.move(x, y)

        self.window.show_all()

        # Whether to display toolbar or not
        self.on_showToolbar_toggled(self.ui.get_object("showToolbar"))
        self.list.grab_focus()

        if self.gconf_client.get('start_in_tray'):
            self.window.hide()

        self.toggle_buttons()

        # Connects to the Daemon
        self.iface = None
        iface = get_dbus_interface(common.DBUS_INTERFACE, common.DBUS_PATH)
        if iface:
            iface.connect_to_signal("bill_edited", self.reloadTreeView)
            iface.connect_to_signal("bill_edited", self.reloadTimeline)
            iface.connect_to_signal("show_main_window", self.window.show)
            self.iface = iface
            timeout_add(2000, self._send_tray_hints)

        self.set_action_strings()
        self.ui.connect_signals(self)

        # populate treeview
        self.reloadTreeView()
        self.notify = NotifyIcon(self)

        # Integrate with Ubuntu Unity
        if UNITY:
            self.unity = UnityIntegration(self)