Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
gajim-plugins
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
Evert Mouw
gajim-plugins
Commits
3577b497
Commit
3577b497
authored
11 years ago
by
Dicson
Browse files
Options
Downloads
Patches
Plain Diff
AppindicatorSupportPlugin. coding style
parent
dfdbc044
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
appindicator_integration/plugin.py
+28
-27
28 additions, 27 deletions
appindicator_integration/plugin.py
with
28 additions
and
27 deletions
appindicator_integration/plugin.py
+
28
−
27
View file @
3577b497
...
@@ -13,7 +13,7 @@ import gtkgui_helpers
...
@@ -13,7 +13,7 @@ import gtkgui_helpers
import
gtk
import
gtk
try
:
try
:
import
appindicator
import
appindicator
except
:
except
:
appindicator
=
None
appindicator
=
None
# Gajim
# Gajim
from
common
import
gajim
from
common
import
gajim
...
@@ -21,14 +21,14 @@ from plugins import GajimPlugin
...
@@ -21,14 +21,14 @@ from plugins import GajimPlugin
from
plugins.plugin
import
GajimPluginException
from
plugins.plugin
import
GajimPluginException
from
plugins.helpers
import
log_calls
from
plugins.helpers
import
log_calls
class
AppindicatorIntegrationPlugin
(
GajimPlugin
):
class
AppindicatorIntegrationPlugin
(
GajimPlugin
):
@log_calls
(
"
AppindicatorIntegrationPlugin
"
)
@log_calls
(
"
AppindicatorIntegrationPlugin
"
)
def
init
(
self
):
def
init
(
self
):
self
.
description
=
_
(
'
This plugin integrates Gajim with the appindicator.
\n
'
self
.
description
=
_
(
'
This plugin integrates Gajim with the appindicator.
\n
'
'
You must have python-appindicator (and Gajim obviously) installed to enable this plugin.
\n
'
)
'
You must have python-appindicator (and Gajim obviously)
'
'
installed to enable this plugin.
\n
'
)
self
.
config_dialog
=
None
self
.
config_dialog
=
None
self
.
test_activatable
()
self
.
test_activatable
()
...
@@ -42,32 +42,33 @@ class AppindicatorIntegrationPlugin(GajimPlugin):
...
@@ -42,32 +42,33 @@ class AppindicatorIntegrationPlugin(GajimPlugin):
@log_calls
(
"
AppindicatorIntegrationPlugin
"
)
@log_calls
(
"
AppindicatorIntegrationPlugin
"
)
def
activate
(
self
):
def
activate
(
self
):
self
.
events
=
{}
;
self
.
events
=
{}
self
.
show_gajim_menu_item
=
gtk
.
MenuItem
(
'
Show/hide roster
'
)
self
.
show_gajim_menu_item
=
gtk
.
MenuItem
(
'
Show/hide roster
'
)
self
.
show_gajim_menu_item
.
connect
(
"
activate
"
,
self
.
roster_raise
)
self
.
show_gajim_menu_item
.
connect
(
"
activate
"
,
self
.
roster_raise
)
self
.
show_gajim_menu_item
.
show
()
self
.
show_gajim_menu_item
.
show
()
self
.
event_separator
=
gtk
.
SeparatorMenuItem
()
;
self
.
event_separator
=
gtk
.
SeparatorMenuItem
()
self
.
menuEventInsertIndex
=
2
;
self
.
menuEventInsertIndex
=
2
itemExitSeparator
=
gtk
.
SeparatorMenuItem
()
itemExitSeparator
=
gtk
.
SeparatorMenuItem
()
itemExitSeparator
.
show
()
itemExitSeparator
.
show
()
itemExit
=
gtk
.
MenuItem
(
'
Exit
'
)
itemExit
=
gtk
.
MenuItem
(
'
Exit
'
)
itemExit
.
connect
(
"
activate
"
,
self
.
on_exit_menuitem_activate
)
itemExit
.
connect
(
"
activate
"
,
self
.
on_exit_menuitem_activate
)
itemExit
.
show
()
itemExit
.
show
()
self
.
menu
=
gtk
.
Menu
()
self
.
menu
=
gtk
.
Menu
()
self
.
menu
.
append
(
self
.
show_gajim_menu_item
)
self
.
menu
.
append
(
self
.
show_gajim_menu_item
)
self
.
menu
.
append
(
self
.
event_separator
)
self
.
menu
.
append
(
self
.
event_separator
)
self
.
menu
.
append
(
itemExitSeparator
)
self
.
menu
.
append
(
itemExitSeparator
)
self
.
menu
.
append
(
itemExit
)
self
.
menu
.
append
(
itemExit
)
self
.
menu
.
show
()
self
.
menu
.
show
()
self
.
indicator
=
appindicator
.
Indicator
(
"
Gajim
"
,
"
tray-online
"
,
appindicator
.
CATEGORY_APPLICATION_STATUS
)
self
.
indicator
=
appindicator
.
Indicator
(
"
Gajim
"
,
"
tray-online
"
,
self
.
indicator
.
set_attention_icon
(
"
tray-message
"
)
appindicator
.
CATEGORY_APPLICATION_STATUS
)
self
.
indicator
.
set_status
(
appindicator
.
STATUS_ACTIVE
)
self
.
indicator
.
set_attention_icon
(
"
tray-message
"
)
self
.
indicator
.
set_status
(
appindicator
.
STATUS_ACTIVE
)
self
.
indicator
.
set_menu
(
self
.
menu
)
self
.
indicator
.
set_menu
(
self
.
menu
)
gajim
.
events
.
event_added_subscribe
(
self
.
on_event_added
)
gajim
.
events
.
event_added_subscribe
(
self
.
on_event_added
)
...
@@ -79,7 +80,7 @@ class AppindicatorIntegrationPlugin(GajimPlugin):
...
@@ -79,7 +80,7 @@ class AppindicatorIntegrationPlugin(GajimPlugin):
gajim
.
events
.
event_removed_unsubscribe
(
self
.
on_event_removed
)
gajim
.
events
.
event_removed_unsubscribe
(
self
.
on_event_removed
)
if
hasattr
(
self
,
'
indicator
'
):
if
hasattr
(
self
,
'
indicator
'
):
self
.
indicator
.
set_status
(
appindicator
.
STATUS_PASSIVE
)
self
.
indicator
.
set_status
(
appindicator
.
STATUS_PASSIVE
)
del
self
.
indicator
del
self
.
indicator
def
roster_raise
(
self
,
widget
,
data
=
None
):
def
roster_raise
(
self
,
widget
,
data
=
None
):
...
@@ -91,14 +92,13 @@ class AppindicatorIntegrationPlugin(GajimPlugin):
...
@@ -91,14 +92,13 @@ class AppindicatorIntegrationPlugin(GajimPlugin):
def
on_exit_menuitem_activate
(
self
,
widget
,
data
=
None
):
def
on_exit_menuitem_activate
(
self
,
widget
,
data
=
None
):
gajim
.
interface
.
roster
.
on_quit_request
()
gajim
.
interface
.
roster
.
on_quit_request
()
def
event_raise
(
self
,
widget
,
event
):
def
event_raise
(
self
,
widget
,
event
):
gajim
.
interface
.
handle_event
(
event
.
account
,
event
.
jid
,
event
.
type_
)
gajim
.
interface
.
handle_event
(
event
.
account
,
event
.
jid
,
event
.
type_
)
win
=
gajim
.
interface
.
roster
.
window
win
=
gajim
.
interface
.
roster
.
window
if
not
win
.
is_active
():
if
not
win
.
is_active
():
win
.
present
()
win
.
present
()
def
on_event_added
(
self
,
event
):
def
on_event_added
(
self
,
event
):
account
=
event
.
account
account
=
event
.
account
jid
=
event
.
jid
jid
=
event
.
jid
...
@@ -118,7 +118,7 @@ class AppindicatorIntegrationPlugin(GajimPlugin):
...
@@ -118,7 +118,7 @@ class AppindicatorIntegrationPlugin(GajimPlugin):
else
:
else
:
contact
=
jid
contact
=
jid
elif
event
.
type_
==
"
pm
"
or
event
.
type_
==
"
printed_pm
"
:
elif
event
.
type_
==
"
pm
"
or
event
.
type_
==
"
printed_pm
"
:
contact
=
gajim
.
get_nick_from_jid
(
gajim
.
get_room_from_fjid
(
jid
))
+
\
contact
=
gajim
.
get_nick_from_jid
(
gajim
.
get_room_from_fjid
(
jid
))
+
\
"
/
"
+
gajim
.
get_room_and_nick_from_fjid
(
jid
)[
1
]
"
/
"
+
gajim
.
get_room_and_nick_from_fjid
(
jid
)[
1
]
elif
event
.
type_
==
"
printed_marked_gc_msg
"
:
elif
event
.
type_
==
"
printed_marked_gc_msg
"
:
contact
=
gajim
.
get_nick_from_jid
(
gajim
.
get_room_from_fjid
(
jid
))
contact
=
gajim
.
get_nick_from_jid
(
gajim
.
get_room_from_fjid
(
jid
))
...
@@ -138,7 +138,7 @@ class AppindicatorIntegrationPlugin(GajimPlugin):
...
@@ -138,7 +138,7 @@ class AppindicatorIntegrationPlugin(GajimPlugin):
fd
=
fopen
(
file_path
,
'
rb
'
)
fd
=
fopen
(
file_path
,
'
rb
'
)
data
=
fd
.
read
()
data
=
fd
.
read
()
icon
=
gtkgui_helpers
.
get_pixbuf_from_data
(
data
)
icon
=
gtkgui_helpers
.
get_pixbuf_from_data
(
data
)
item
=
gtk
.
ImageMenuItem
(
contact
+
"
(1)
"
)
item
=
gtk
.
ImageMenuItem
(
contact
+
"
(1)
"
)
if
icon
:
if
icon
:
item
.
setImage
(
icon
)
item
.
setImage
(
icon
)
item
.
set_always_show_image
(
True
)
item
.
set_always_show_image
(
True
)
...
@@ -147,25 +147,26 @@ class AppindicatorIntegrationPlugin(GajimPlugin):
...
@@ -147,25 +147,26 @@ class AppindicatorIntegrationPlugin(GajimPlugin):
self
.
menu
.
insert
(
item
,
self
.
menuEventInsertIndex
)
self
.
menu
.
insert
(
item
,
self
.
menuEventInsertIndex
)
self
.
event_separator
.
show
()
self
.
event_separator
.
show
()
self
.
events
[
key
]
=
{}
self
.
events
[
key
]
=
{}
self
.
events
[
key
][
'
item
'
]
=
item
self
.
events
[
key
][
'
item
'
]
=
item
self
.
events
[
key
][
'
contact
'
]
=
contact
self
.
events
[
key
][
'
contact
'
]
=
contact
self
.
events
[
key
][
'
events
'
]
=
[
event
]
self
.
events
[
key
][
'
events
'
]
=
[
event
]
else
:
else
:
self
.
events
[
key
][
'
events
'
].
append
(
event
)
self
.
events
[
key
][
'
events
'
].
append
(
event
)
item
=
self
.
events
[
key
][
'
item
'
]
item
=
self
.
events
[
key
][
'
item
'
]
item
.
set_label
(
self
.
events
[
key
][
'
contact
'
]
+
"
(
"
+
str
(
len
(
self
.
events
[
key
][
'
events
'
]))
+
"
)
"
)
item
.
set_label
(
self
.
events
[
key
][
'
contact
'
]
+
self
.
indicator
.
set_status
(
appindicator
.
STATUS_ATTENTION
)
"
(
"
+
str
(
len
(
self
.
events
[
key
][
'
events
'
]))
+
"
)
"
)
self
.
indicator
.
set_status
(
appindicator
.
STATUS_ATTENTION
)
def
on_event_removed
(
self
,
events
):
def
on_event_removed
(
self
,
events
):
for
event
in
events
:
for
event
in
events
:
key
=
(
event
.
account
,
event
.
jid
)
key
=
(
event
.
account
,
event
.
jid
)
if
key
in
self
.
events
and
\
if
key
in
self
.
events
and
event
in
self
.
events
[
key
][
'
events
'
]:
event
in
self
.
events
[
key
][
'
events
'
]:
self
.
events
[
key
][
'
events
'
].
remove
(
event
)
self
.
events
[
key
][
'
events
'
].
remove
(
event
)
if
len
(
self
.
events
[
key
][
'
events
'
])
==
0
:
# remove indicator
if
len
(
self
.
events
[
key
][
'
events
'
])
==
0
:
# remove indicator
self
.
menu
.
remove
(
self
.
events
[
key
][
'
item
'
])
self
.
menu
.
remove
(
self
.
events
[
key
][
'
item
'
])
del
self
.
events
[
key
]
del
self
.
events
[
key
]
self
.
event_separator
.
hide
()
self
.
event_separator
.
hide
()
self
.
indicator
.
set_status
(
appindicator
.
STATUS_ACTIVE
)
self
.
indicator
.
set_status
(
appindicator
.
STATUS_ACTIVE
)
else
:
else
:
self
.
events
[
key
][
'
item
'
].
connect
(
"
activate
"
,
self
.
event_raise
,
self
.
events
[
key
][
'
events
'
][
-
1
])
self
.
events
[
key
][
'
item
'
].
connect
(
"
activate
"
,
\ No newline at end of file
self
.
event_raise
,
self
.
events
[
key
][
'
events
'
][
-
1
])
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