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
eta
gajim
Commits
2410121d
Commit
2410121d
authored
6 years ago
by
Philipp Hörist
Browse files
Options
Downloads
Patches
Plain Diff
Add dedicated zeroconf menu
parent
828ae5bb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
gajim/app_actions.py
+307
-280
307 additions, 280 deletions
gajim/app_actions.py
gajim/application.py
+56
-55
56 additions, 55 deletions
gajim/application.py
gajim/gui_menu_builder.py
+26
-20
26 additions, 20 deletions
gajim/gui_menu_builder.py
with
389 additions
and
355 deletions
gajim/app_actions.py
+
307
−
280
View file @
2410121d
This diff is collapsed.
Click to expand it.
gajim/application.py
+
56
−
55
View file @
2410121d
...
...
@@ -284,37 +284,14 @@ class GajimApplication(Gtk.Application):
def
add_actions
(
self
):
'''
Build Application Actions
'''
from
gajim.app_actions
import
AppActions
action
=
AppActions
(
self
)
self
.
account_actions
=
[
(
'
-start-single-chat
'
,
action
.
on_single_message
,
'
online
'
,
'
s
'
),
(
'
-join-groupchat
'
,
action
.
on_join_gc
,
'
online
'
,
'
s
'
),
(
'
-add-contact
'
,
action
.
on_add_contact
,
'
online
'
,
'
s
'
),
(
'
-services
'
,
action
.
on_service_disco
,
'
online
'
,
'
s
'
),
(
'
-profile
'
,
action
.
on_profile
,
'
feature
'
,
'
s
'
),
(
'
-xml-console
'
,
action
.
on_xml_console
,
'
always
'
,
'
s
'
),
(
'
-server-info
'
,
action
.
on_server_info
,
'
online
'
,
'
s
'
),
(
'
-archive
'
,
action
.
on_archiving_preferences
,
'
feature
'
,
'
s
'
),
(
'
-sync-history
'
,
action
.
on_history_sync
,
'
online
'
,
'
s
'
),
(
'
-privacylists
'
,
action
.
on_privacy_lists
,
'
feature
'
,
'
s
'
),
(
'
-send-server-message
'
,
action
.
on_send_server_message
,
'
online
'
,
'
s
'
),
(
'
-set-motd
'
,
action
.
on_set_motd
,
'
online
'
,
'
s
'
),
(
'
-update-motd
'
,
action
.
on_update_motd
,
'
online
'
,
'
s
'
),
(
'
-delete-motd
'
,
action
.
on_delete_motd
,
'
online
'
,
'
s
'
),
(
'
-activate-bookmark
'
,
action
.
on_activate_bookmark
,
'
online
'
,
'
a{sv}
'
),
(
'
-open-event
'
,
action
.
on_open_event
,
'
always
'
,
'
a{sv}
'
),
(
'
-import-contacts
'
,
action
.
on_import_contacts
,
'
online
'
,
'
s
'
),
]
from
gajim
import
app_actions
# General Stateful Actions
act
=
Gio
.
SimpleAction
.
new_stateful
(
'
merge
'
,
None
,
GLib
.
Variant
.
new_boolean
(
app
.
config
.
get
(
'
mergeaccounts
'
)))
act
.
connect
(
'
change-state
'
,
action
.
on_merge_accounts
)
act
.
connect
(
'
change-state
'
,
app_
action
s
.
on_merge_accounts
)
self
.
add_action
(
act
)
act
=
Gio
.
SimpleAction
.
new_stateful
(
...
...
@@ -324,40 +301,38 @@ class GajimApplication(Gtk.Application):
# General Actions
self
.
general_actions
=
[
(
'
quit
'
,
action
.
on_quit
),
(
'
accounts
'
,
action
.
on_accounts
),
(
'
add-account
'
,
action
.
on_add_account
),
(
'
manage-proxies
'
,
action
.
on_manage_proxies
),
(
'
start-chat
'
,
action
.
on_new_chat
),
(
'
bookmarks
'
,
action
.
on_manage_bookmarks
),
(
'
history-manager
'
,
action
.
on_history_manager
),
(
'
preferences
'
,
action
.
on_preferences
),
(
'
plugins
'
,
action
.
on_plugins
),
(
'
file-transfer
'
,
action
.
on_file_transfers
),
(
'
history
'
,
action
.
on_history
),
(
'
shortcuts
'
,
action
.
on_keyboard_shortcuts
),
(
'
features
'
,
action
.
on_features
),
(
'
content
'
,
action
.
on_contents
),
(
'
about
'
,
action
.
on_about
),
(
'
faq
'
,
action
.
on_faq
),
(
'
ipython
'
,
action
.
toggle_ipython
),
(
'
show-next-pending-event
'
,
action
.
show_next_pending_event
),
general_actions
=
[
(
'
quit
'
,
app_
action
s
.
on_quit
),
(
'
accounts
'
,
app_
action
s
.
on_accounts
),
(
'
add-account
'
,
app_
action
s
.
on_add_account
),
(
'
manage-proxies
'
,
app_
action
s
.
on_manage_proxies
),
(
'
start-chat
'
,
app_
action
s
.
on_new_chat
),
(
'
bookmarks
'
,
app_
action
s
.
on_manage_bookmarks
),
(
'
history-manager
'
,
app_
action
s
.
on_history_manager
),
(
'
preferences
'
,
app_
action
s
.
on_preferences
),
(
'
plugins
'
,
app_
action
s
.
on_plugins
),
(
'
file-transfer
'
,
app_
action
s
.
on_file_transfers
),
(
'
history
'
,
app_
action
s
.
on_history
),
(
'
shortcuts
'
,
app_
action
s
.
on_keyboard_shortcuts
),
(
'
features
'
,
app_
action
s
.
on_features
),
(
'
content
'
,
app_
action
s
.
on_contents
),
(
'
about
'
,
app_
action
s
.
on_about
),
(
'
faq
'
,
app_
action
s
.
on_faq
),
(
'
ipython
'
,
app_
action
s
.
toggle_ipython
),
(
'
show-next-pending-event
'
,
app_
action
s
.
show_next_pending_event
),
]
act
=
Gio
.
SimpleAction
.
new
(
'
add-contact
'
,
GLib
.
VariantType
.
new
(
'
s
'
))
act
.
connect
(
"
activate
"
,
action
.
on_add_contact_jid
)
act
.
connect
(
"
activate
"
,
app_
action
s
.
on_add_contact_jid
)
self
.
add_action
(
act
)
for
action
in
self
.
general_actions
:
for
action
in
general_actions
:
action_name
,
func
=
action
act
=
Gio
.
SimpleAction
.
new
(
action_name
,
None
)
act
.
connect
(
"
activate
"
,
func
)
self
.
add_action
(
act
)
accounts_list
=
sorted
(
app
.
config
.
get_per
(
'
accounts
'
))
if
'
Local
'
in
accounts_list
:
accounts_list
.
remove
(
'
Local
'
)
if
not
accounts_list
:
return
if
len
(
accounts_list
)
>
1
:
...
...
@@ -366,10 +341,38 @@ class GajimApplication(Gtk.Application):
else
:
self
.
add_account_actions
(
accounts_list
[
0
])
def
add_account_actions
(
self
,
account
):
def
_get_account_actions
(
self
,
account
):
from
gajim
import
app_actions
if
account
==
'
Local
'
:
return
for
action
in
self
.
account_actions
:
return
[
(
'
-xml-console
'
,
app_actions
.
on_xml_console
,
'
always
'
,
'
s
'
)
]
return
[
(
'
-start-single-chat
'
,
app_actions
.
on_single_message
,
'
online
'
,
'
s
'
),
(
'
-join-groupchat
'
,
app_actions
.
on_join_gc
,
'
online
'
,
'
s
'
),
(
'
-add-contact
'
,
app_actions
.
on_add_contact
,
'
online
'
,
'
s
'
),
(
'
-services
'
,
app_actions
.
on_service_disco
,
'
online
'
,
'
s
'
),
(
'
-profile
'
,
app_actions
.
on_profile
,
'
feature
'
,
'
s
'
),
(
'
-xml-console
'
,
app_actions
.
on_xml_console
,
'
always
'
,
'
s
'
),
(
'
-server-info
'
,
app_actions
.
on_server_info
,
'
online
'
,
'
s
'
),
(
'
-archive
'
,
app_actions
.
on_archiving_preferences
,
'
feature
'
,
'
s
'
),
(
'
-sync-history
'
,
app_actions
.
on_history_sync
,
'
online
'
,
'
s
'
),
(
'
-privacylists
'
,
app_actions
.
on_privacy_lists
,
'
feature
'
,
'
s
'
),
(
'
-send-server-message
'
,
app_actions
.
on_send_server_message
,
'
online
'
,
'
s
'
),
(
'
-set-motd
'
,
app_actions
.
on_set_motd
,
'
online
'
,
'
s
'
),
(
'
-update-motd
'
,
app_actions
.
on_update_motd
,
'
online
'
,
'
s
'
),
(
'
-delete-motd
'
,
app_actions
.
on_delete_motd
,
'
online
'
,
'
s
'
),
(
'
-activate-bookmark
'
,
app_actions
.
on_activate_bookmark
,
'
online
'
,
'
a{sv}
'
),
(
'
-open-event
'
,
app_actions
.
on_open_event
,
'
always
'
,
'
a{sv}
'
),
(
'
-import-contacts
'
,
app_actions
.
on_import_contacts
,
'
online
'
,
'
s
'
),
]
def
add_account_actions
(
self
,
account
):
for
action
in
self
.
_get_account_actions
(
account
):
action_name
,
func
,
state
,
type_
=
action
action_name
=
account
+
action_name
if
self
.
lookup_action
(
action_name
):
...
...
@@ -383,14 +386,12 @@ class GajimApplication(Gtk.Application):
self
.
add_action
(
act
)
def
remove_account_actions
(
self
,
account
):
for
action
in
self
.
account_actions
:
for
action
in
self
.
_get_
account_actions
(
account
)
:
action_name
=
account
+
action
[
0
]
self
.
remove_action
(
action_name
)
def
set_account_actions_state
(
self
,
account
,
new_state
=
False
):
if
account
==
'
Local
'
:
return
for
action
in
self
.
account_actions
:
for
action
in
self
.
_get_account_actions
(
account
):
action_name
,
_
,
state
,
_
=
action
if
not
new_state
and
state
in
(
'
online
'
,
'
feature
'
):
# We go offline
...
...
This diff is collapsed.
Click to expand it.
gajim/gui_menu_builder.py
+
26
−
20
View file @
2410121d
...
...
@@ -727,25 +727,29 @@ def get_account_menu(account):
sub menu: list
'''
account_menu
=
[
(
'
-add-contact
'
,
_
(
'
Add Contact…
'
)),
(
'
-join-groupchat
'
,
_
(
'
Join Group Chat
'
)),
(
'
-profile
'
,
_
(
'
Profile
'
)),
(
'
-services
'
,
_
(
'
Discover Services
'
)),
(
'
-start-single-chat
'
,
_
(
'
Send Single Message…
'
)),
(
_
(
'
Advanced
'
),
[
(
'
-archive
'
,
_
(
'
Archiving Preferences
'
)),
(
'
-sync-history
'
,
_
(
'
Synchronise History
'
)),
(
'
-privacylists
'
,
_
(
'
Privacy Lists
'
)),
(
'
-server-info
'
,
_
(
'
Server Info
'
)),
(
'
-xml-console
'
,
_
(
'
XML Console
'
))
]),
(
_
(
'
Admin
'
),
[
(
'
-send-server-message
'
,
_
(
'
Send Server Message…
'
)),
(
'
-set-motd
'
,
_
(
'
Set MOTD…
'
)),
(
'
-update-motd
'
,
_
(
'
Update MOTD…
'
)),
(
'
-delete-motd
'
,
_
(
'
Delete MOTD…
'
))
]),
]
(
'
-add-contact
'
,
_
(
'
Add Contact…
'
)),
(
'
-join-groupchat
'
,
_
(
'
Join Group Chat
'
)),
(
'
-profile
'
,
_
(
'
Profile
'
)),
(
'
-services
'
,
_
(
'
Discover Services
'
)),
(
'
-start-single-chat
'
,
_
(
'
Send Single Message…
'
)),
(
_
(
'
Advanced
'
),
[
(
'
-archive
'
,
_
(
'
Archiving Preferences
'
)),
(
'
-sync-history
'
,
_
(
'
Synchronise History
'
)),
(
'
-privacylists
'
,
_
(
'
Privacy Lists
'
)),
(
'
-server-info
'
,
_
(
'
Server Info
'
)),
(
'
-xml-console
'
,
_
(
'
XML Console
'
))
]),
(
_
(
'
Admin
'
),
[
(
'
-send-server-message
'
,
_
(
'
Send Server Message…
'
)),
(
'
-set-motd
'
,
_
(
'
Set MOTD…
'
)),
(
'
-update-motd
'
,
_
(
'
Update MOTD…
'
)),
(
'
-delete-motd
'
,
_
(
'
Delete MOTD…
'
))
]),
]
zeroconf_menu
=
[
(
'
-xml-console
'
,
_
(
'
XML Console
'
)),
]
def
build_menu
(
preset
):
menu
=
Gio
.
Menu
()
...
...
@@ -769,6 +773,8 @@ def get_account_menu(account):
menu
.
append_submenu
(
label
,
submenu
)
return
menu
if
account
==
'
Local
'
:
return
build_menu
(
zeroconf_menu
)
return
build_menu
(
account_menu
)
...
...
@@ -781,7 +787,7 @@ def build_accounts_menu():
acc_menu
=
menubar
.
get_item_link
(
menu_position
,
'
submenu
'
)
acc_menu
.
remove_all
()
accounts_list
=
sorted
(
app
.
contacts
.
get_accounts
(
zeroconf
=
False
))
accounts_list
=
sorted
(
app
.
contacts
.
get_accounts
())
if
not
accounts_list
:
no_accounts
=
_
(
'
No Accounts available
'
)
acc_menu
.
append_item
(
Gio
.
MenuItem
.
new
(
no_accounts
,
None
))
...
...
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