Esempio n. 1
0
 def __get_addon(self, obj, callback=display_message):
     """
     Get an addon from the wiki or file system and install it.
     """
     path = self.install_addon_path.get_text()
     load_addon_file(path, callback)
     self.uistate.viewmanager.do_reg_plugins(self.dbstate, self.uistate)
     self.__rebuild_load_list()
     self.__rebuild_reg_list()
Esempio n. 2
0
 def __get_addon(self, obj, callback=display_message):
     """
     Get an addon from the wiki or file system and install it.
     """
     path = self.install_addon_path.get_text()
     load_addon_file(path, callback)
     self.uistate.viewmanager.do_reg_plugins(self.dbstate, self.uistate)
     self.__rebuild_load_list()
     self.__rebuild_reg_list()
Esempio n. 3
0
 def __install(self, _obj, _list_obj):
     """ Callback function from the "Install" button
     """
     model, node = self._selection_reg.get_selected()
     if not node:
         return
     path = model.get_path(node)
     pid = model.get_value(node, R_ID)
     status = model.get_value(node, R_STAT)
     if (status & INSTALLED) and not (status & UPDATE):
         self.__uninstall(pid, path)
         return
     for addon in self.addons:
         if addon['i'] == pid:
             name = addon['n']
             fname = addon['z']
     url = "%s/download/%s" % (config.get("behavior.addons-url"), fname)
     load_ok = load_addon_file(url, callback=LOG.debug)
     if not load_ok:
         OkDialog(_("Installation Errors"),
                  _("The following addons had errors: ") +
                  name,
                  parent=self.window)
         return
     self.__rebuild_reg_list(path)
     pdata = self._pmgr.get_plugin(pid)
     if pdata and (status & UPDATE) and (pdata.ptype == VIEW or
                                         pdata.ptype == GRAMPLET):
         self.restart_needed = True
Esempio n. 4
0
 def __install(self, _obj, _list_obj):
     """ Callback function from the "Install" button
     """
     model, node = self._selection_reg.get_selected()
     if not node:
         return
     path = model.get_path(node)
     pid = model.get_value(node, R_ID)
     status = model.get_value(node, R_STAT)
     if (status & INSTALLED) and not (status & UPDATE):
         self.__uninstall(pid, path)
         return
     for addon in self.addons:
         if addon['i'] == pid:
             name = addon['n']
             fname = addon['z']
     url = "%s/download/%s" % (config.get("behavior.addons-url"), fname)
     load_ok = load_addon_file(url, callback=LOG.debug)
     if not load_ok:
         OkDialog(_("Installation Errors"),
                  _("The following addons had errors: ") +
                  name,
                  parent=self.window)
         return
     self.__rebuild_reg_list(path)
     pdata = self._pmgr.get_plugin(pid)
     if (status & UPDATE) and (pdata.ptype == VIEW or
                               pdata.ptype == GRAMPLET):
         self.restart_needed = True
Esempio n. 5
0
 def __get_all_addons(self, obj):
     """
     Get all addons from the wiki and install them.
     """
     from ..utils import ProgressMeter
     pm = ProgressMeter(_("Install all Addons"), _("Installing..."), message_area=True)
     pm.set_pass(total=len(self.addon_model))
     errors = []
     for row in self.addon_model:
         pm.step()
         (help_name, name, ptype, image, desc, use, rating, contact, 
          download, url) = row
         load_addon_file(url, callback=pm.append_message)
     self.uistate.viewmanager.do_reg_plugins(self.dbstate, self.uistate)
     pm.message_area_ok.set_sensitive(True)
     self.__rebuild_load_list()
     self.__rebuild_reg_list()
Esempio n. 6
0
 def __get_all_addons(self, obj):
     """
     Get all addons from the wiki and install them.
     """
     from ..utils import ProgressMeter
     pm = ProgressMeter(_("Install all Addons"), _("Installing..."), message_area=True)
     pm.set_pass(total=len(self.addon_model))
     errors = []
     for row in self.addon_model:
         pm.step()
         (help_name, name, ptype, image, desc, use, rating, contact,
          download, url) = row
         load_addon_file(url, callback=pm.append_message)
     self.uistate.viewmanager.do_reg_plugins(self.dbstate, self.uistate)
     pm.message_area_ok.set_sensitive(True)
     self.__rebuild_load_list()
     self.__rebuild_reg_list()
Esempio n. 7
0
    def install_addons(self, obj):
        """
        Process all of the selected addons.
        """
        self.update_dialog.hide()
        model = self.list.model

        iter = model.get_iter_first()
        length = 0
        while iter:
            iter = model.iter_next(iter)
            if iter:
                length += model.iter_n_children(iter)

        longop = LongOpStatus(
            _("Downloading and installing selected addons..."),
            length,
            1,  # total, increment-by
            can_cancel=True)
        pm = ProgressMonitor(GtkProgressDialog,
                             ("Title", self.window, Gtk.DialogFlags.MODAL))
        pm.add_op(longop)
        count = 0
        if not config.get('behavior.do-not-show-previously-seen-updates'):
            # reset list
            config.get('behavior.previously-seen-updates')[:] = []

        iter = model.get_iter_first()
        while iter:
            for rowcnt in range(model.iter_n_children(iter)):
                child = model.iter_nth_child(iter, rowcnt)
                row = [model.get_value(child, n) for n in range(6)]
                if longop.should_cancel():
                    break
                elif row[0]:  # toggle on
                    load_addon_file(row[4], callback=LOG.debug)
                    count += 1
                else:  # add to list of previously seen, but not installed
                    if row[5] not in config.get(
                            'behavior.previously-seen-updates'):
                        config.get('behavior.previously-seen-updates').append(
                            row[5])
                longop.heartbeat()
                pm._get_dlg()._process_events()
            iter = model.iter_next(iter)

        if not longop.was_cancelled():
            longop.end()
        if count:
            OkDialog(
                _("Done downloading and installing addons"),
                # translators: leave all/any {...} untranslated
                "%s %s" % (ngettext("{number_of} addon was installed.",
                                    "{number_of} addons were installed.",
                                    count).format(number_of=count),
                           _("You need to restart Gramps to see new views.")),
                self.window)
        else:
            OkDialog(_("Done downloading and installing addons"),
                     _("No addons were installed."), self.window)
        self.close()
Esempio n. 8
0
    def install_addons(self, obj):
        """
        Process all of the selected addons.
        """
        self.window.hide()
        model = self.list.model

        iter = model.get_iter_first()
        length = 0
        while iter:
            iter = model.iter_next(iter)
            if iter:
                length += model.iter_n_children(iter)

        longop = LongOpStatus(
            _("Downloading and installing selected addons..."),
            length, 1, # total, increment-by
            can_cancel=True)
        pm = ProgressMonitor(GtkProgressDialog,
                             ("Title", self.window, Gtk.DialogFlags.MODAL))
        pm.add_op(longop)
        count = 0
        if not config.get('behavior.do-not-show-previously-seen-updates'):
            # reset list
            config.get('behavior.previously-seen-updates')[:] = []

        iter = model.get_iter_first()
        errors = []
        while iter:
            for rowcnt in range(model.iter_n_children(iter)):
                child = model.iter_nth_child(iter, rowcnt)
                row = [model.get_value(child, n) for n in range(6)]
                if longop.should_cancel():
                    break
                elif row[0]: # toggle on
                    ok = load_addon_file(row[4], callback=LOG.debug)
                    if ok:
                        count += 1
                    else:
                        errors.append(row[2])
                else: # add to list of previously seen, but not installed
                    if row[5] not in config.get('behavior.previously-seen-updates'):
                        config.get('behavior.previously-seen-updates').append(row[5])
                longop.heartbeat()
                pm._get_dlg()._process_events()
            iter = model.iter_next(iter)

        if not longop.was_cancelled():
            longop.end()
        if errors:
            OkDialog(_("Installation Errors"),
                     _("The following addons had errors: ") +
                     ", ".join(errors),
                     self.window)
        if count:
            OkDialog(_("Done downloading and installing addons"),
                     # translators: leave all/any {...} untranslated
                     "%s %s" % (ngettext("{number_of} addon was installed.",
                                         "{number_of} addons were installed.",
                                         count).format(number_of=count),
                                _("You need to restart Gramps to see new views.")),
                     self.window)
        else:
            OkDialog(_("Done downloading and installing addons"),
                     _("No addons were installed."),
                     self.window)
        self.window.destroy()