Группа :: Система/Настройка/Печать
Пакет: system-config-printer
Главная Изменения Спек Патчи Sources Загрузить Gear Bugs and FR Repocop
Патч: system-config-printer-1.5.11-plugins.patch
Скачать
Скачать
jobviewer.py | 40 ++++++++++++++++++++++++++++++++++++++--
1 file changed, 38 insertions(+), 2 deletions(-)
diff --git a/jobviewer.py b/jobviewer.py
index 6d9309ff..8f134fc7 100644
--- a/jobviewer.py
+++ b/jobviewer.py
@@ -1,5 +1,5 @@
-
## Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Red Hat, Inc.
+# -*- coding: utf-8 -*-
## Authors:
## Tim Waugh <twaugh@redhat.com>
## Jiri Popelka <jpopelka@redhat.com>
@@ -50,6 +50,7 @@ import config
import statereason
import errordialogs
from functools import reduce
+import pluggy
cups.require("1.9.47")
@@ -69,6 +70,7 @@ pkgdata = config.pkgdatadir
ICON="printer"
ICON_SIZE=22
SEARCHING_ICON="document-print-preview"
+APP_NAME = "system_config_printer"
# We need to call Notify.init before we can check the server for caps
Notify.init('System Config Printer Notification')
@@ -377,6 +379,24 @@ class CancelJobsOperation(GObject.GObject):
reply_handler=self.cancelJob_finish,
error_handler=self.cancelJob_error)
+pluginspec = pluggy.HookspecMarker(APP_NAME)
+
+@pluginspec
+def add_actions (host, job_action_group):
+ """Initialize your plugin with the JobViewer itself in the host argument and add actions using job_action_group.add_actions()."""
+
+@pluginspec
+def adjust_ui (job_ui_manager):
+ """Tweak the UI with Gtk.UIManager job_ui_manager."""
+
+@pluginspec
+def adjust_context_menu (job_action_group, job_context_menu):
+ """Add actions to the Gtk.Menu job_context_menu."""
+
+@pluginspec
+def adjust_toolbar (job_action_group, toolbar):
+ """Adjust the Gtk.Toolbar toolbar as necessary."""
+
class JobViewer (GtkGUI):
required_job_attributes = set(['job-k-octets',
'job-name',
@@ -422,6 +442,10 @@ class JobViewer (GtkGUI):
self.authenticated_jobs = set() # of job IDs
self.ops = []
+ self.plugins = pluggy.PluginManager (APP_NAME)
+ self.plugins.add_hookspecs (sys.modules[__name__])
+ self.plugins.load_setuptools_entrypoints (APP_NAME)
+
self.getWidgets ({"JobsWindow":
["JobsWindow",
"treeview",
@@ -450,7 +474,11 @@ class JobViewer (GtkGUI):
("authenticate-job", None, _("_Authenticate"), None, None,
self.on_job_authenticate_activate),
("job-attributes", None, _("_View Attributes"), None, None,
- self.on_job_attributes_activate),
+ self.on_job_attributes_activate)
+ ])
+ self.plugins.hook.add_actions (host=self,
+ job_action_group=job_action_group)
+ job_action_group.add_actions ([
("close", Gtk.STOCK_CLOSE, None, "<ctrl>w",
_("Close this window"), self.on_delete_event)
])
@@ -472,6 +500,8 @@ class JobViewer (GtkGUI):
</ui>
"""
)
+ self.plugins.hook.adjust_ui (job_ui_manager=self.job_ui_manager)
+
self.job_ui_manager.ensure_update ()
self.JobsWindow.add_accel_group (self.job_ui_manager.get_accel_group ())
self.job_context_menu = Gtk.Menu ()
@@ -500,6 +530,9 @@ class JobViewer (GtkGUI):
item.show ()
self.job_context_menu.append (item)
+ self.plugins.hook.adjust_context_menu (job_action_group=job_action_group,
+ job_context_menu=self.job_context_menu)
+
for action_name in ["cancel-job",
"delete-job",
"hold-job",
@@ -514,6 +547,9 @@ class JobViewer (GtkGUI):
item.show ()
self.toolbar.insert (item, -1)
+ self.plugins.hook.adjust_toolbar (job_action_group=job_action_group,
+ toolbar=self.toolbar)
+
for skip, ellipsize, name, setter in \
[(False, False, _("Job"), self._set_job_job_number_text),
(True, False, _("User"), self._set_job_user_text),