Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Weblate
gajim
Commits
b99c10f6
Commit
b99c10f6
authored
15 years ago
by
Yann Leboulanger
Browse files
Options
Downloads
Patches
Plain Diff
add ged.py file
parent
32050296
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/common/ged.py
+64
-0
64 additions, 0 deletions
src/common/ged.py
with
64 additions
and
0 deletions
src/common/ged.py
0 → 100644
+
64
−
0
View file @
b99c10f6
# -*- coding: utf-8 -*-
## This file is part of Gajim.
##
## Gajim is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published
## by the Free Software Foundation; version 3 only.
##
## Gajim is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
##
'''
Global Events Dispatcher module.
:author: Mateusz Biliński <mateusz@bilinski.it>
:since: 8th August 2008
:copyright: Copyright (2008) Mateusz Biliński <mateusz@bilinski.it>
:license: GPL
'''
import
logging
log
=
logging
.
getLogger
(
'
gajim.common.ged
'
)
PRECORE
=
30
CORE
=
40
POSTCORE
=
50
class
GlobalEventsDispatcher
(
object
):
def
__init__
(
self
):
self
.
handlers
=
{}
def
register_event_handler
(
self
,
event_name
,
priority
,
handler
):
if
event_name
in
self
.
handlers
:
handlers_list
=
self
.
handlers
[
event_name
]
i
=
0
for
i
,
h
in
enumerate
(
handlers_list
):
if
priority
<
h
[
0
]:
break
handlers_list
.
insert
(
i
,
(
priority
,
handler
))
else
:
self
.
handlers
[
event_name
]
=
[(
priority
,
handler
)]
def
remove_event_handler
(
self
,
event_name
,
priority
,
handler
):
if
event_name
in
self
.
handlers
:
try
:
self
.
handlers
[
event_name
].
remove
((
priority
,
handler
))
except
ValueError
,
error
:
log
.
warn
(
'''
Function (%s) with priority
"
%s
"
never registered
as handler of event
"
%s
"
. Couldn
\'
t remove. Error: %s
'''
%
(
handler
,
priority
,
event_name
,
error
))
def
raise_event
(
self
,
event_name
,
*
args
,
**
kwargs
):
log
.
debug
(
'
%s
\n
Args: %s
'
%
(
event_name
,
str
(
args
)))
if
event_name
in
self
.
handlers
:
for
priority
,
handler
in
self
.
handlers
[
event_name
]:
handler
(
*
args
,
**
kwargs
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment