Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Vittorio Monti
chatty
Commits
30493e68
Commit
30493e68
authored
Feb 10, 2020
by
Andrea Schaefer
Browse files
Add notification sound
parent
29fa32b3
Changes
4
Hide whitespace changes
Inline
Side-by-side
debian/control
View file @
30493e68
...
...
@@ -13,6 +13,7 @@ Build-Depends:
libsqlite3-dev,
libgee-0.8-dev,
libfolks-dev,
libgsound-dev,
meson,
Standards-Version: 4.2.1
Homepage: https://source.puri.sm/Librem5/chatty
...
...
sm.puri.Chatty.json
View file @
30493e68
...
...
@@ -211,6 +211,16 @@
}
]
},
{
"name"
:
"gsound"
,
"sources"
:
[
{
"type"
:
"archive"
,
"url"
:
"https://download.gnome.org/sources/gsound/1.0/gsound-1.0.2.tar.xz"
,
"sha256"
:
"bba8ff30eea815037e53bee727bbd5f0b6a2e74d452a7711b819a7c444e78e53"
}
]
},
{
"name"
:
"purism-chatty"
,
"buildsystem"
:
"meson"
,
...
...
src/chatty-conversation.c
View file @
30493e68
...
...
@@ -8,6 +8,7 @@
#define G_LOG_DOMAIN "chatty-conversation"
#include <glib/gi18n.h>
#include <gsound.h>
#include "chatty-window.h"
#include "chatty-manager.h"
#include "chatty-icons.h"
...
...
@@ -27,6 +28,15 @@
static
GHashTable
*
ht_sms_id
=
NULL
;
static
GHashTable
*
ht_emoticon
=
NULL
;
typedef
struct
{
GSoundContext
*
ctx
;
gchar
*
sound_theme
;
}
ConvSound
;
static
ConvSound
*
conv_gs
;
const
char
*
avatar_colors
[
16
]
=
{
"E57373"
,
"F06292"
,
"BA68C8"
,
"9575CD"
,
"7986CB"
,
"64B5F6"
,
"4FC3F7"
,
"4DD0E1"
,
"4DB6AC"
,
"81C784"
,
"AED581"
,
"DCE775"
,
...
...
@@ -2116,6 +2126,21 @@ chatty_conv_write_conversation (PurpleConversation *conv,
NULL
);
}
else
if
(
pcm
.
flags
&
PURPLE_MESSAGE_RECV
)
{
if
(
buddy
&&
purple_blist_node_get_bool
(
node
,
"chatty-notifications"
))
{
g_autoptr
(
GError
)
error
=
NULL
;
gsound_context_play_simple
(
conv_gs
->
ctx
,
NULL
,
&
error
,
GSOUND_ATTR_MEDIA_ROLE
,
"event"
,
GSOUND_ATTR_EVENT_ID
,
"message-new-instant"
,
GSOUND_ATTR_EVENT_DESCRIPTION
,
_
(
"New instant message"
),
NULL
);
if
(
error
)
{
g_warning
(
"Error: %s: %s"
,
__func__
,
error
->
message
);
}
buddy_name
=
purple_buddy_get_alias
(
buddy
);
titel
=
g_strdup_printf
(
_
(
"New message from %s"
),
buddy_name
);
...
...
@@ -2800,6 +2825,51 @@ cb_ht_check_items (gpointer key,
}
static
void
chatty_conv_init_gsound
(
void
)
{
GtkSettings
*
settings
;
GHashTable
*
attr
;
g_autoptr
(
GError
)
error
=
NULL
;
conv_gs
=
g_new0
(
ConvSound
,
1
);
conv_gs
->
ctx
=
gsound_context_new
(
NULL
,
&
error
);
settings
=
gtk_settings_get_default
();
g_object_get
(
settings
,
"gtk-sound-theme-name"
,
&
conv_gs
->
sound_theme
,
NULL
);
attr
=
g_hash_table_new
(
g_str_hash
,
g_str_equal
);
g_hash_table_insert
(
attr
,
GSOUND_ATTR_APPLICATION_ID
,
CHATTY_APP_ID
);
g_hash_table_insert
(
attr
,
GSOUND_ATTR_APPLICATION_NAME
,
CHATTY_APP_NAME
);
g_hash_table_insert
(
attr
,
GSOUND_ATTR_APPLICATION_ICON_NAME
,
CHATTY_APP_ID
);
if
(
conv_gs
->
sound_theme
)
g_hash_table_insert
(
attr
,
GSOUND_ATTR_CANBERRA_XDG_THEME_NAME
,
conv_gs
->
sound_theme
);
gsound_context_set_attributesv
(
conv_gs
->
ctx
,
attr
,
&
error
);
g_hash_table_unref
(
attr
);
if
(
!
conv_gs
->
ctx
)
g_warning
(
"Error: %s: %s"
,
__func__
,
error
->
message
);
}
static
void
chatty_conv_init_destroy
(
void
)
{
g_object_unref
(
conv_gs
->
ctx
);
g_free
(
conv_gs
->
sound_theme
);
g_free
(
conv_gs
);
}
/**
* chatty_conv_destroy:
* @conv: a PurpleConversation
...
...
@@ -2986,12 +3056,15 @@ chatty_conversations_init (void)
NULL
);
chatty_conv_init_emoticon_translations
();
chatty_conv_init_gsound
();
}
void
chatty_conversations_uninit
(
void
)
{
chatty_conv_init_destroy
();
g_hash_table_destroy
(
ht_sms_id
);
purple_prefs_disconnect_by_handle
(
chatty_conversations_get_handle
());
purple_signals_disconnect_by_handle
(
chatty_conversations_get_handle
());
...
...
src/meson.build
View file @
30493e68
...
...
@@ -55,6 +55,7 @@ chatty_deps = [
dependency('sqlite3', version: '>=3.0.0'),
dependency('gee-0.8'),
dependency('folks'),
dependency('gsound'),
libebook_dep,
libm_dep,
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment