Esempio n. 1
0
 def show_context_menu(self, event):
     selected_item = self.get_selected_item()[0]
     if selected_item.__class__.__name__ == "AssetCategory":
         context_menu = self.builder.get_object("asset_allocation_contextmenu")
         # accounts
         account_menu = self.builder.get_object("aa_add_account_menu")
         all_accounts = account.get_all_accounts()
         if all_accounts:
             account_menu.set_visible(True)
             menu = Gtk.Menu()
             account_menu.set_submenu(menu)
             for acc in all_accounts:
                 if selected_item not in acc.asset_categories:
                     item = Gtk.MenuItem(label=acc.name)
                     item.connect("activate", self.on_aa_add_account, selected_item, acc)
                     menu.append(item)
         # positions
         positions_menu = self.builder.get_object("aa_add_positions_menu")
         positions = position.get_all_portfolio_positions()
         if positions:
             positions_menu.set_visible(True)
             menu = Gtk.Menu()
             positions_menu.set_submenu(menu)
             for pos in positions:
                 if pos.quantity > 0:
                     item = Gtk.MenuItem(label=pos.asset.name)
                     item.connect("activate", self.on_aa_add_position, selected_item, pos)
                     menu.append(item)
             account_menu.show_all()
     else:
         context_menu = self.builder.get_object("asset_allocation_item_contextmenu")
     context_menu.show_all()
     context_menu.popup(None, None, None, None, event.button, event.time)
Esempio n. 2
0
    def _init_widgets(self):
        self.export_button = self.add_button(_('Export'), Gtk.ResponseType.ACCEPT)
        self.export_button.set_sensitive(False)
        vbox = self.get_content_area()
        fileBox = Gtk.HBox()
        vbox.pack_start(fileBox, False, False, 0)
        fileBox.pack_start(Gtk.Label(_('Location to export')), False, False, 0)
        self.fcbutton = Gtk.FileChooserButton()
        self.fcbutton.set_title(_('Folder to export to'))
        self.fcbutton.set_action(Gtk.FileChooserAction.SELECT_FOLDER)
        self.file = None
        self.fcbutton.connect('file-set', self._on_file_set)
        folder = self.config.get_option('last_export_folder')
        if folder is not None:
            self.fcbutton.set_current_folder(folder)
            self.folder = folder
        fileBox.pack_start(self.fcbutton, True, True, 0)
        accBox = Gtk.HBox()
        vbox.pack_start(accBox, False, False, 0)
        accBox.pack_start(Gtk.Label(_('Account')), False, False, 0)
        model = Gtk.ListStore(object, str)
        i = 0
        active = -1
        for acc in account.get_all_accounts():
            model.append([acc, acc.name])
            if self.account == acc:
                active = i
            i += 1
        self.account_cb = Gtk.ComboBox()
        self.account_cb.set_model(model)
        if active > -1:
            self.account_cb.set_active(active)
        cell = Gtk.CellRendererText()
        self.account_cb.pack_start(cell, True)
        self.account_cb.add_attribute(cell, 'text', 1)
        self.account_cb.connect('changed', self._on_account_changed)
        accBox.pack_start(self.account_cb, False, True, 0)
        frame = Gtk.Frame()
        frame.set_label(_('Transactions'))
        sw = Gtk.ScrolledWindow()
        sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
        self.tree = TransactionTree()
        frame.add(sw)

        sw.add(self.tree)
        vbox.pack_start(frame, True, True, 0)
        self.show_all()
Esempio n. 3
0
    def _load_items(self):
        portfolios = container.get_all_portfolios()
        if len(portfolios) > 1:
            all_pf = container.AllPortfolio()
            all_pf.name = "<i>%s</i>" % (_('All'),)
            self.insert_portfolio(all_pf)
        for pf in portfolios:
            self.insert_portfolio(pf)
        for wl in container.get_all_watchlists():
            self.insert_watchlist(wl)

        accounts = account.get_all_accounts()
        if len(accounts) > 1:
            all_account = account.AllAccount()
            all_account.name = "<i>%s</i>" % (_('All'),)
            self.insert_account(all_account)
        for acc in accounts:
            self.insert_account(acc)
        self.tree.expand_all()
Esempio n. 4
0
 def _load_accounts(self):
     accounts = account.get_all_accounts()
     for account_type, type_name in account.yield_account_types():
         iterator = self.model.append(None, [None, type_name, 0.0, 0, None, None, Pango.Weight.BOLD])
         ta_count = 0
         balance = 0
         for acc in accounts:
             if acc.type == account_type:
                 new_iter = self.model.append(iterator, [acc,
                            acc.name,
                            acc.balance,
                            len(acc.transactions),
                            acc.birthday,
                            acc.lastday,
                            Pango.Weight.NORMAL
                           ])
                 new_row = self.model[new_iter]
                 balance += acc.balance
                 ta_count += new_row[3]
                 self.model[iterator] = [None, type_name, balance, ta_count, None, None, Pango.Weight.BOLD]
Esempio n. 5
0
    def _init_widgets(self):
        self.fcbutton = self.builder.get_object("file_chooser")
        self.account_cb = self.builder.get_object("account_combobox")
        category_assignment_button = self.builder.get_object("assignment_button")
        self.filename = None
        folder = self.config.get_option('last_csv_folder')
        if folder is not None:
            self.fcbutton.set_current_folder(folder)
        model = self.builder.get_object("account_liststore")
        i = 0
        active = -1
        for acc in account.get_all_accounts():
            model.append([acc, acc.name])
            if self.account == acc:
                active = i
            i += 1

        if active > -1:
            self.account_cb.set_active(active)

        category_assignment_button.set_active(self.b_categories)
        sw = self.builder.get_object("sw")
        self.tree = PreviewTree()
        sw.add(self.tree)