Ejemplo n.º 1
0
    def gotomap(self, obj):
        """
        Run the map service
        """
        #First test if any map service is available
        if not len(self.mapservicedata):
            msg = _("No map service is available.")
            msg2 = _("Check your installation.")
            ErrorDialog(msg, msg2, parent=self.uistate.window)
            return

        place_handles = self.selected_handles()
        try:
            place_handle = self.selected_handles()[0]
        except IndexError:
            msg = _("No place selected.")
            msg2 = _("You need to select a place to be able to view it"
                     " on a map. Some Map Services might support multiple"
                     " selections.")
            ErrorDialog(msg, msg2, parent=self.uistate.window)
            return

        #TODO: support for descriptions in some cases. For now, pass None
        #TODO: Later this might be 'Birth of William' ....
        places = [(x, None) for x in place_handles]

        #run the mapservice:
        pmgr = GuiPluginManager.get_instance()
        serv = self.mapservicedata[self.mapservice]
        mod = pmgr.load_plugin(serv)
        if mod:
            servfunc = eval('mod.' +  serv.mapservice)
            servfunc()(self.dbstate.db, places, self.uistate)
        else:
            print('Failed to load map plugin, see Plugin Manager')
Ejemplo n.º 2
0
    def __create_maps_menu_actions(self):
        """
        Function creating a menu and actions that are used as dropdown menu
        from the menutoolbutton
        """
        menu = Gtk.Menu()

        #select the map services to show
        self.mapservicedata = {}
        servlist = GuiPluginManager.get_instance().get_reg_mapservices()
        for i, pdata in enumerate(servlist):
            key = pdata.id.replace(' ', '-')
            add_menuitem(menu, pdata.name, None,
                               make_callback(self.set_mapservice, key))
            self.mapservicedata[key] = pdata

        return menu
Ejemplo n.º 3
0
    def __init__(self, dbstate, uistate, track):
        self.uistate = uistate
        self.dbstate = dbstate
        self._show_builtins = None
        self._show_hidden = None
        self.options = PluginManagerOptions('pluginmanager')
        #tool.Tool.__init__(self, dbstate, options_class, 'pluginmanager')
        self.options.load_previous_values()
        self.options_dict = self.options.handler.options_dict
        self.window = Gtk.Dialog(title=TITLE)
        ManagedWindow.__init__(self, uistate, track, self.__class__)
        self.set_window(self.window, None, TITLE, None)
        self._pmgr = GuiPluginManager.get_instance()
        self._preg = PluginRegister.get_instance()
        #obtain hidden plugins from the pluginmanager
        self.hidden = self._pmgr.get_hidden_plugin_ids()
        self.setup_configs('interface.pluginstatus', 750, 400)

        help_btn = self.window.add_button(  # pylint: disable=no-member
            _("_Help"), Gtk.ResponseType.HELP)

        update_btn = self.window.add_button(  # pylint: disable=no-member
            _("Check for updated addons now"), UPDATE_RES)
        btn_box = help_btn.get_parent()
        btn_box.set_child_non_homogeneous(update_btn, True)

        if __debug__:
            # Only show the "Reload" button when in debug mode
            # (without -O on the command line)
            reload_btn = self.window.add_button(  # pylint: disable=no-member
                _("Reload"), RELOAD_RES)
            btn_box.set_child_non_homogeneous(reload_btn, True)
        self.window.add_button(_('_Close'), Gtk.ResponseType.CLOSE)
        labeltitle, widget = self.registered_plugins_panel(None)
        self.window.vbox.pack_start(widget, True, True, 0)
        sep = Gtk.Separator.new(Gtk.Orientation.HORIZONTAL)
        self.window.vbox.pack_start(sep, False, False, 3)
        self.restart_needed = False
        self.window.connect('response', self.done)
        self.show()
        self.__populate_reg_list()
Ejemplo n.º 4
0
    def __create_maps_menu_actions(self):
        """
        Function creating a menu and actions that are used as dropdown menu
        from the menutoolbutton
        """
        _bar = '''
            <item>
              <attribute name="action">win.MapChoice</attribute>
              <attribute name="target">%s</attribute>
              <attribute name="label">%s</attribute>
            </item>
            '''
        menu = ''

        #select the map services to show
        self.mapservicedata = {}
        servlist = GuiPluginManager.get_instance().get_reg_mapservices()
        for pdata in servlist:
            key = pdata.id.replace(' ', '-')
            menu += _bar % (key, pdata.name)
            self.mapservicedata[key] = pdata

        if not self.mapservicedata:
            return self.additional_ui
        if self.mapservice not in self.mapservicedata:
            #stored val no longer exists, use the most recent key instead
            self.set_mapservice(None, key)

        self._add_toggle_action('MapChoice', self.set_mapservice, '',
                                self.mapservice)

        label = self.mapservice_label()
        _ui = self.additional_ui[:]
        _ui.append(self.map_ui_menu % menu)
        _ui.append(self.map_ui % label)
        return _ui
Ejemplo n.º 5
0
    def __create_maps_menu_actions(self):
        """
        Function creating a menu and actions that are used as dropdown menu
        from the menutoolbutton
        """
        _bar = '''
            <item>
              <attribute name="action">win.MapChoice</attribute>
              <attribute name="target">%s</attribute>
              <attribute name="label" translatable="yes">%s</attribute>
            </item>
            '''
        menu = ''

        #select the map services to show
        self.mapservicedata = {}
        servlist = GuiPluginManager.get_instance().get_reg_mapservices()
        for pdata in servlist:
            key = pdata.id.replace(' ', '-')
            menu += _bar % (key, pdata.name)
            self.mapservicedata[key] = pdata

        if not self.mapservicedata:
            return self.additional_ui
        if self.mapservice not in self.mapservicedata:
            #stored val no longer exists, use the most recent key instead
            self.set_mapservice(None, key)

        self._add_toggle_action('MapChoice', self.set_mapservice, '',
                                self.mapservice)

        label = self.mapservice_label()
        _ui = self.additional_ui[:]
        _ui.append(self.map_ui_menu % menu)
        _ui.append(self.map_ui % label)
        return _ui
Ejemplo n.º 6
0
    def __init__(self, dbstate, uistate, track):
        self.uistate = uistate
        self.dbstate = dbstate
        self._show_builtins = None
        self._show_hidden = None
        self.options = PluginManagerOptions('pluginmanager')
        #tool.Tool.__init__(self, dbstate, options_class, 'pluginmanager')
        self.options.load_previous_values()
        self.options_dict = self.options.handler.options_dict
        self.window = Gtk.Dialog(title=TITLE)
        ManagedWindow.__init__(self, uistate, track, self.__class__)
        self.set_window(self.window, None, TITLE, None)
        self._pmgr = GuiPluginManager.get_instance()
        self._preg = PluginRegister.get_instance()
        # obtain hidden plugins from the pluginmanager
        self.hidden = self._pmgr.get_hidden_plugin_ids()
        self.setup_configs('interface.pluginstatus', 750, 400)

        help_btn = self.window.add_button(  # pylint: disable=no-member
            _("_Help"), Gtk.ResponseType.HELP)
        self.btn_box = help_btn.get_parent()
        self.btn_box.set_child_non_homogeneous(help_btn, True)

        # filter input box
        self.filter_entry = Gtk.SearchEntry()
        self.filter_entry.set_tooltip_text(
            _("Enter search words to filter the addons.\n"
              "All the words must be present somewhere in the row or\n"
              "the addon filename to be included in the search.\n"
              "Word case and order is ignored."))
        self.filter_entry.set_placeholder_text(_("Search..."))
        self.btn_box.pack_start(self.filter_entry, True, True, 0)
        #self.btn_box.set_child_non_homogeneous(self.filter_entry, True)
        self.filter_entry.connect('search-changed', self.filter_str_changed)

        update_btn = self.window.add_button(  # pylint: disable=no-member
            _("Check for updated addons now"), UPDATE_RES)
        self.btn_box.set_child_non_homogeneous(update_btn, True)

        if __debug__:
            # Only show the "Reload" button when in debug mode
            # (without -O on the command line)
            reload_btn = self.window.add_button(  # pylint: disable=no-member
                _("Reload"), RELOAD_RES)
            self.btn_box.set_child_non_homogeneous(reload_btn, True)
            _w0, _wx_ = reload_btn.get_preferred_width()
        else:
            _w0 = 0

        cls_btn = self.window.add_button(_('_Close'), Gtk.ResponseType.CLOSE)
        self.btn_box.set_child_non_homogeneous(cls_btn, True)

        _w1, dummy = help_btn.get_preferred_width()
        _w2, dummy = cls_btn.get_preferred_width()
        _w3, dummy = update_btn.get_preferred_width()
        #_wa, dummy = self.window.get_size()
        _we = 790 - _w0 - _w1 - _w2 - _w3 - 60
        self.filter_entry.set_size_request(_we, -1)

        labeltitle, widget = self.registered_plugins_panel(None)
        self.window.vbox.pack_start(widget, True, True, 0)
        sep = Gtk.Separator.new(Gtk.Orientation.HORIZONTAL)
        self.window.vbox.pack_start(sep, False, False, 3)
        self.restart_needed = False
        self.window.connect('response', self.done)
        self.show()
        self.__populate_reg_list()
Ejemplo n.º 7
0
             authors_email=["*****@*****.**"],
             viewclass='LifeLineChartAncestorView',
             stock_icon='gramps-lifelineancestorchart-bw',
             )
    register(VIEW,
             id='lifelinechartdescendantview',
             name=_("Life Line Descendant Chart"),
             category=("Ancestry", _("Charts")),
             description=_("Persons and their relation in a time based chart"),
             version = '1.3.17',
             gramps_target_version="5.1",
             status=STABLE,
             fname='lifelinechartview.py',
             authors=["Christian Schulze"],
             authors_email=["*****@*****.**"],
             viewclass='LifeLineChartDescendantView',
             stock_icon='gramps-lifelinedescendantchart-bw',
             )

# prevent the view from starting if there is a problem; we still need to
# register to support plugin manager 'installed' and addon updates correctly
if locals().get('uistate'):
    from gramps.gui.pluginmanager import GuiPluginManager
    pmgr = GuiPluginManager.get_instance()
    if some_import_error:
        pmgr.hide_plugin('lifelinechartancestorview')
        pmgr.hide_plugin('lifelinechartdescendantview')
    elif 'lifelinechartancestorview' in pmgr.get_hidden_plugin_ids():
        pmgr.unhide_plugin('lifelinechartancestorview')
        pmgr.unhide_plugin('lifelinechartdescendantview')
Ejemplo n.º 8
0
    def __init__(self, dbstate, uistate, track):
        self.uistate = uistate
        self.dbstate = dbstate
        self._show_builtins = None
        self._show_hidden = None
        self.options = PluginManagerOptions('pluginmanager')
        #tool.Tool.__init__(self, dbstate, options_class, 'pluginmanager')
        self.options.load_previous_values()
        self.options_dict = self.options.handler.options_dict
        self.window = Gtk.Dialog(title=TITLE)
        ManagedWindow.__init__(self, uistate, track, self.__class__)
        self.set_window(self.window, None, TITLE, None)
        self._pmgr = GuiPluginManager.get_instance()
        self._preg = PluginRegister.get_instance()
        # obtain hidden plugins from the pluginmanager
        self.hidden = self._pmgr.get_hidden_plugin_ids()
        self.setup_configs('interface.pluginstatus', 750, 400)

        help_btn = self.window.add_button(  # pylint: disable=no-member
            _("_Help"), Gtk.ResponseType.HELP)
        self.btn_box = help_btn.get_parent()
        self.btn_box.set_child_non_homogeneous(help_btn, True)

        # filter input box
        self.filter_entry = Gtk.SearchEntry()
        self.filter_entry.set_tooltip_text(
            _("Enter search words to filter the addons.\n"
              "All the words must be present somewhere in the row or\n"
              "the addon filename to be included in the search.\n"
              "Word case and order is ignored."))
        self.filter_entry.set_placeholder_text(_("Search..."))
        self.btn_box.pack_start(self.filter_entry, True, True, 0)
        #self.btn_box.set_child_non_homogeneous(self.filter_entry, True)
        self.filter_entry.connect('search-changed', self.filter_str_changed)

        update_btn = self.window.add_button(  # pylint: disable=no-member
            _("Check for updated addons now"), UPDATE_RES)
        self.btn_box.set_child_non_homogeneous(update_btn, True)

        if __debug__:
            # Only show the "Reload" button when in debug mode
            # (without -O on the command line)
            reload_btn = self.window.add_button(  # pylint: disable=no-member
                _("Reload"), RELOAD_RES)
            self.btn_box.set_child_non_homogeneous(reload_btn, True)
            _w0, _wx_ = reload_btn.get_preferred_width()
        else:
            _w0 = 0

        cls_btn = self.window.add_button(_('_Close'), Gtk.ResponseType.CLOSE)
        self.btn_box.set_child_non_homogeneous(cls_btn, True)

        _w1, dummy = help_btn.get_preferred_width()
        _w2, dummy = cls_btn.get_preferred_width()
        _w3, dummy = update_btn.get_preferred_width()
        _wa, dummy = self.window.get_size()
        _we = _wa - _w0 - _w1 - _w2 - _w3 - 63
        self.filter_entry.set_size_request(_we, -1)

        labeltitle, widget = self.registered_plugins_panel(None)
        self.window.vbox.pack_start(widget, True, True, 0)
        sep = Gtk.Separator.new(Gtk.Orientation.HORIZONTAL)
        self.window.vbox.pack_start(sep, False, False, 3)
        self.restart_needed = False
        self.window.connect('response', self.done)
        self.show()
        self.__populate_reg_list()
Ejemplo n.º 9
0
 def test_load_plugin(self):
     pdata = Familychroniclestest.__get_user_report('FamilyChronicles')
     pmgr = GuiPluginManager.get_instance()
     module = pmgr.load_plugin(pdata)
     assert module is not None