Skip to content

Commit

Permalink
fix(Plugins): adapt and fix plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
t00m committed May 30, 2024
1 parent ed68010 commit 13c9fd6
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 11 deletions.
23 changes: 13 additions & 10 deletions data/resources/plugins/menurepo.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,19 @@ def do_deactivate(self):

def repo_settings_menu(self, *args):
# Add menutitem to menu for single items
if self.app.get_widget('workspace-menu-repo-section-in-menuitem-settings') is None:
section_common_in = self.app.get_widget('workspace-menu-repo-section-in')
menuitem = self.factory.create_menuitem(name='repo_settings', label=_('Repository settings'), callback=self.show_repo_settings, data=None, shortcuts=[])
self.app.add_widget('workspace-menu-repo-section-in-menuitem-settings', menuitem)
section_common_in.append_item(menuitem)

# ~ submenu_export_multi = self.app.get_widget('workspace-menu-selection-submenu-export')
# ~ menuitem = self.factory.create_menuitem('export-to-csv', '...to CSV', self.export, None, [])
# ~ self.app.add_widget('workspace-menu-multiple-menu-export-item-export2csv', menuitem)
# ~ submenu_export_multi.append_item(menuitem)
try:
if self.app.get_widget('workspace-menu-repo-section-in-menuitem-settings') is None:
section_common_in = self.app.get_widget('workspace-menu-repo-section-in')
menuitem = self.factory.create_menuitem(name='repo_settings', label=_('Repository settings'), callback=self.show_repo_settings, data=None, shortcuts=[])
self.app.add_widget('workspace-menu-repo-section-in-menuitem-settings', menuitem)
section_common_in.append_item(menuitem)

# ~ submenu_export_multi = self.app.get_widget('workspace-menu-selection-submenu-export')
# ~ menuitem = self.factory.create_menuitem('export-to-csv', '...to CSV', self.export, None, [])
# ~ self.app.add_widget('workspace-menu-multiple-menu-export-item-export2csv', menuitem)
# ~ submenu_export_multi.append_item(menuitem)
except Exception as error:
self.log.error(error)

def show_repo_settings(self, *args):
self.app.show_stack_page_by_name('settings_repo')
2 changes: 1 addition & 1 deletion data/resources/plugins/renameitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ def document_rename_single(self, doc):
self.log.debug("Rename %s", doc)
rename = self.app.get_widget('rename')
rename.set_data(doc)
self.app.show_stack_page_by_name('rename')
self.actions.show_stack_page_by_name('rename')
10 changes: 10 additions & 0 deletions data/resources/plugins/repoinfo.plugin
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Plugin]
Module=repoinfo
Name=MiAZRepositoryInfo
Loader=Python3
Description=View/Edit repository info
Authors=Tomás Vírseda <[email protected]>
Copyright=Copyright © 2023 Tomás Vírseda
Website=http://github.com/t00m/MiAZ
Help=http://github.com/t00m/MiAZ/README.adoc
Version=0.1
61 changes: 61 additions & 0 deletions data/resources/plugins/repoinfo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-

"""
# File: delete.py
# Author: Tomás Vírseda
# License: GPL v3
# Description: Plugin for deleting items
"""

import os
import tempfile
from gettext import gettext as _

from gi.repository import Gtk
from gi.repository import GObject
from gi.repository import Peas

from MiAZ.backend.log import get_logger
from MiAZ.frontend.desktop.widgets.settings import MiAZRepoSettings


class MiAZRepositoryInfoPlugin(GObject.GObject, Peas.Activatable):
__gtype_name__ = 'MiAZRepositoryInfoPlugin'
object = GObject.Property(type=GObject.Object)

def __init__(self):
self.log = get_logger('Plugin.RepoInfo')

def do_activate(self):
API = self.object
self.app = API.app
self.actions = self.app.get_service('actions')
self.backend = self.app.get_service('backend')
self.factory = self.app.get_service('factory')
self.config = self.backend.get_config()
self.util = self.app.get_service('util')
self.repository = self.app.get_service('repo')
self.workspace = API.app.get_widget('workspace')
self.workspace.connect('workspace-loaded', self.add_menuitem)


def do_deactivate(self):
self.log.debug("Plugin deactivation not implemented")
API = self.object

def add_menuitem(self, *args):
if self.app.get_widget('workspace-menu-selection-section-app-repository-info') is None:
section_app = self.app.get_widget('workspace-menu-selection-section-app')
menuitem = self.factory.create_menuitem('repoinfo', _('Repository properties'), self.repository_info, None, [])
self.app.add_widget('workspace-menu-selection-section-app-repository-info', menuitem)
section_app.append_item(menuitem)

def repository_info(self, *args):
window_main = self.app.get_widget('window')
window_settings = self.app.get_widget('settings-repo')
if window_settings is None:
window_settings = self.app.add_widget('settings-repo', MiAZRepoSettings(self.app))
window_settings.set_transient_for(window_main)
window_settings.set_modal(True)
window_settings.present()

0 comments on commit 13c9fd6

Please sign in to comment.