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
967d2785
Commit
967d2785
authored
19 years ago
by
nkour
Browse files
Options
Downloads
Patches
Plain Diff
[jim++] sound events show in UI as translatable nice words. [me] refactor the whole thing
parent
11fedebb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/common/helpers.py
+1
-1
1 addition, 1 deletion
src/common/helpers.py
src/config.py
+47
-30
47 additions, 30 deletions
src/config.py
src/gtkgui.glade
+2
-2
2 additions, 2 deletions
src/gtkgui.glade
with
50 additions
and
33 deletions
src/common/helpers.py
+
1
−
1
View file @
967d2785
...
...
@@ -408,7 +408,7 @@ def play_sound(event):
if
path_to_soundfile
==
'
beep
'
:
print
'
\a
'
# make a speaker beep
return
if
not
os
.
path
.
exists
(
path_to_soundfile
):
if
path_to_soundfile
is
None
or
not
os
.
path
.
exists
(
path_to_soundfile
):
return
if
os
.
name
==
'
nt
'
:
try
:
...
...
This diff is collapsed.
Click to expand it.
src/config.py
+
47
−
30
View file @
967d2785
...
...
@@ -299,7 +299,9 @@ class PreferencesWindow:
#sounds treeview
self
.
sound_tree
=
self
.
xml
.
get_widget
(
'
sounds_treeview
'
)
model
=
gtk
.
ListStore
(
str
,
bool
,
str
)
# active, event ui name, path to sound file, event_config_name
model
=
gtk
.
ListStore
(
bool
,
str
,
str
,
str
)
self
.
sound_tree
.
set_model
(
model
)
col
=
gtk
.
TreeViewColumn
(
_
(
'
Active
'
))
...
...
@@ -308,13 +310,13 @@ class PreferencesWindow:
renderer
.
set_property
(
'
activatable
'
,
True
)
renderer
.
connect
(
'
toggled
'
,
self
.
sound_toggled_cb
)
col
.
pack_start
(
renderer
)
col
.
set_attributes
(
renderer
,
active
=
1
)
col
.
set_attributes
(
renderer
,
active
=
0
)
col
=
gtk
.
TreeViewColumn
(
_
(
'
Event
'
))
self
.
sound_tree
.
append_column
(
col
)
renderer
=
gtk
.
CellRendererText
()
col
.
pack_start
(
renderer
)
col
.
set_attributes
(
renderer
,
text
=
0
)
col
.
set_attributes
(
renderer
,
text
=
1
)
col
=
gtk
.
TreeViewColumn
(
_
(
'
Sound
'
))
self
.
sound_tree
.
append_column
(
col
)
...
...
@@ -731,9 +733,9 @@ class PreferencesWindow:
self
.
on_checkbutton_toggled
(
widget
,
'
ask_offline_status
'
)
def
on_sounds_treemodel_row_changed
(
self
,
model
,
path
,
iter
):
sound_event
=
model
.
get_value
(
iter
,
0
)
.
decode
(
'
utf-8
'
)
sound_event
=
model
[
iter
][
3
]
.
decode
(
'
utf-8
'
)
gajim
.
config
.
set_per
(
'
soundevents
'
,
sound_event
,
'
enabled
'
,
bool
(
model
[
path
][
1
]))
bool
(
model
[
path
][
0
]))
gajim
.
config
.
set_per
(
'
soundevents
'
,
sound_event
,
'
path
'
,
model
[
iter
][
2
].
decode
(
'
utf-8
'
))
gajim
.
interface
.
save_config
()
...
...
@@ -883,13 +885,27 @@ class PreferencesWindow:
model
[
path
][
1
]
=
not
model
[
path
][
1
]
def
fill_sound_treeview
(
self
):
sounds
=
gajim
.
config
.
get_per
(
'
soundevents
'
)
model
=
self
.
sound_tree
.
get_model
()
model
.
clear
()
for
sound
in
sounds
:
val
=
gajim
.
config
.
get_per
(
'
soundevents
'
,
sound
,
'
enabled
'
)
path
=
gajim
.
config
.
get_per
(
'
soundevents
'
,
sound
,
'
path
'
)
model
.
append
((
sound
,
val
,
path
))
# NOTE: sounds_ui_names MUST have all items of
# sounds = gajim.config.get_per('soundevents') as keys
sounds_dict
=
{
'
first_message_received
'
:
_
(
'
First Message Received
'
),
'
next_message_received
'
:
_
(
'
Next Message Received
'
),
'
contact_connected
'
:
_
(
'
Contact Connected
'
),
'
contact_disconnected
'
:
_
(
'
Contact Disconnected
'
),
'
message_sent
'
:
_
(
'
Message Sent
'
),
'
muc_message_highlight
'
:
_
(
'
Group Chat Message Highlight
'
),
'
muc_message_received
'
:
_
(
'
Group Chat Message Received
'
)
}
for
sound_event_config_name
,
sound_ui_name
in
sounds_dict
.
items
():
enabled
=
gajim
.
config
.
get_per
(
'
soundevents
'
,
sound_event_config_name
,
'
enabled
'
)
path
=
gajim
.
config
.
get_per
(
'
soundevents
'
,
sound_event_config_name
,
'
path
'
)
model
.
append
((
enabled
,
sound_ui_name
,
path
,
sound_event_config_name
))
def
on_treeview_sounds_cursor_changed
(
self
,
widget
,
data
=
None
):
(
model
,
iter
)
=
self
.
sound_tree
.
get_selection
().
get_selected
()
...
...
@@ -897,14 +913,14 @@ class PreferencesWindow:
if
not
iter
:
sounds_entry
.
set_text
(
''
)
return
str
=
model
[
iter
][
2
]
sounds_entry
.
set_text
(
str
)
path_to_snd_file
=
model
[
iter
][
2
]
sounds_entry
.
set_text
(
path_to_snd_file
)
def
on_b
utton_sounds
_clicked
(
self
,
widget
,
data
=
None
):
def
on_b
rowse_for_sounds_button
_clicked
(
self
,
widget
,
data
=
None
):
(
model
,
iter
)
=
self
.
sound_tree
.
get_selection
().
get_selected
()
if
not
iter
:
return
file
=
model
[
iter
][
2
].
decode
(
'
utf-8
'
)
path_to_snd_
file
=
model
[
iter
][
2
].
decode
(
'
utf-8
'
)
dialog
=
gtk
.
FileChooserDialog
(
_
(
'
Choose Sound
'
),
None
,
gtk
.
FILE_CHOOSER_ACTION_OPEN
,
(
gtk
.
STOCK_CANCEL
,
gtk
.
RESPONSE_CANCEL
,
...
...
@@ -927,40 +943,41 @@ class PreferencesWindow:
dialog
.
add_filter
(
filter
)
dialog
.
set_filter
(
filter
)
file
=
os
.
path
.
join
(
os
.
getcwd
(),
file
)
dialog
.
set_filename
(
file
)
file
=
''
path_to_snd_
file
=
os
.
path
.
join
(
os
.
getcwd
(),
path_to_snd_
file
)
dialog
.
set_filename
(
path_to_snd_
file
)
path_to_snd_
file
=
''
while
True
:
response
=
dialog
.
run
()
if
response
!=
gtk
.
RESPONSE_OK
:
break
file
=
dialog
.
get_filename
()
path_to_snd_
file
=
dialog
.
get_filename
()
try
:
file
=
file
.
decode
(
sys
.
getfilesystemencoding
())
path_to_snd_file
=
path_to_snd_
file
.
decode
(
sys
.
getfilesystemencoding
())
except
:
pass
if
os
.
path
.
exists
(
file
):
if
os
.
path
.
exists
(
path_to_snd_
file
):
break
dialog
.
destroy
()
if
file
:
directory
=
os
.
path
.
dirname
(
file
)
if
path_to_snd_
file
:
directory
=
os
.
path
.
dirname
(
path_to_snd_
file
)
gajim
.
config
.
set
(
'
last_sounds_dir
'
,
directory
)
self
.
xml
.
get_widget
(
'
sounds_entry
'
).
set_text
(
file
)
model
.
set_value
(
iter
,
2
,
file
)
model
.
set_value
(
iter
,
1
,
1
)
self
.
xml
.
get_widget
(
'
sounds_entry
'
).
set_text
(
path_to_snd_file
)
model
[
iter
][
2
]
=
path_to_snd_file
# set new path to sounds_model
model
[
iter
][
0
]
=
True
# set the sound to enabled
def
on_sounds_entry_changed
(
self
,
widget
):
path_to_file
=
widget
.
get_text
()
path_to_
snd_
file
=
widget
.
get_text
()
model
,
iter
=
self
.
sound_tree
.
get_selection
().
get_selected
()
model
.
set_value
(
iter
,
2
,
path_to_file
)
model
.
set_value
(
iter
,
1
,
1
)
model
[
iter
][
2
]
=
path_to_snd_file
# set new path to sounds_model
model
[
iter
][
0
]
=
True
# set the sound to enabled
def
on_play_button_clicked
(
self
,
widget
):
model
,
iter
=
self
.
sound_tree
.
get_selection
().
get_selected
()
if
not
iter
:
return
event
=
model
[
iter
][
0
]
helpers
.
play_sound
(
event
)
snd_
event
_config_name
=
model
[
iter
][
3
]
helpers
.
play_sound
(
snd_
event
_config_name
)
def
on_open_advanced_editor_button_clicked
(
self
,
widget
,
data
=
None
):
if
gajim
.
interface
.
instances
.
has_key
(
'
advanced_config
'
):
...
...
This diff is collapsed.
Click to expand it.
src/gtkgui.glade
+
2
−
2
View file @
967d2785
...
...
@@ -5178,14 +5178,14 @@ Disabled</property>
</child>
<child>
<widget class="GtkButton" id="sounds_button">
<widget class="GtkButton" id="
browse_for_
sounds_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label">...</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_b
utton_sounds
_clicked" last_modification_time="
Wed, 09
Feb 200
5 23:29
:5
6
GMT"/>
<signal name="clicked" handler="on_b
rowse_for_sounds_button
_clicked" last_modification_time="
Thu, 16
Feb 200
6 14:51
:5
4
GMT"/>
</widget>
<packing>
<property name="padding">0</property>
...
...
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