Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Mohammed Sadiq
chatty
Commits
88fe69dd
Commit
88fe69dd
authored
Nov 04, 2019
by
Andrea Schaefer
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'icon-improvements' into 'master'
Icon improvements See merge request
Librem5/chatty!139
parents
71e24aa2
a7675b4b
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
72 additions
and
32 deletions
+72
-32
src/chatty-connection.c
src/chatty-connection.c
+3
-3
src/chatty-conversation.c
src/chatty-conversation.c
+23
-12
src/chatty-folks.c
src/chatty-folks.c
+8
-11
src/chatty-icons.c
src/chatty-icons.c
+28
-0
src/chatty-icons.h
src/chatty-icons.h
+1
-0
src/chatty-notify.c
src/chatty-notify.c
+7
-5
src/chatty-notify.h
src/chatty-notify.h
+2
-1
No files found.
src/chatty-connection.c
View file @
88fe69dd
...
...
@@ -177,7 +177,7 @@ chatty_connection_connected (PurpleConnection *gc)
message
=
g_strdup_printf
(
"Account %s reconnected"
,
user_name
);
if
(
!
sms_match
||
(
sms_match
&&
sms_notifications
))
{
chatty_notify_show_notification
(
NULL
,
message
,
CHATTY_NOTIFY_ACCOUNT_CONNECTED
,
NULL
);
chatty_notify_show_notification
(
NULL
,
message
,
CHATTY_NOTIFY_ACCOUNT_CONNECTED
,
NULL
,
NULL
);
}
g_free
(
message
);
...
...
@@ -307,7 +307,7 @@ chatty_connection_report_disconnect_reason (PurpleConnection *gc,
// in the 'cb_sms_modem_added' callback
if
(
sms_notifications
)
{
message
=
g_strdup_printf
(
"SMS disconnected: %s"
,
text
);
chatty_notify_show_notification
(
user_name
,
message
,
CHATTY_NOTIFY_ACCOUNT_GENERIC
,
NULL
);
chatty_notify_show_notification
(
user_name
,
message
,
CHATTY_NOTIFY_ACCOUNT_GENERIC
,
NULL
,
NULL
);
g_free
(
message
);
}
...
...
@@ -350,7 +350,7 @@ chatty_connection_report_disconnect_reason (PurpleConnection *gc,
chatty_dialogs_update_connection_status
();
message
=
g_strdup_printf
(
"Account %s disconnected: %s"
,
user_name
,
text
);
chatty_notify_show_notification
(
NULL
,
message
,
CHATTY_NOTIFY_ACCOUNT_DISCONNECTED
,
NULL
);
chatty_notify_show_notification
(
NULL
,
message
,
CHATTY_NOTIFY_ACCOUNT_DISCONNECTED
,
NULL
,
NULL
);
g_free
(
message
);
}
...
...
src/chatty-conversation.c
View file @
88fe69dd
...
...
@@ -11,6 +11,7 @@
#include "chatty-window.h"
#include "chatty-icons.h"
#include "chatty-lurch.h"
#include "chatty-buddy-list.h"
#include "chatty-purple-init.h"
#include "chatty-message-list.h"
#include "chatty-conversation.h"
...
...
@@ -2195,28 +2196,38 @@ chatty_conv_write_conversation (PurpleConversation *conv,
timestamp
=
g_strdup
(
"00:00"
);
}
if
(
buddy
&&
purple_blist_node_get_bool
(
node
,
"chatty-notifications"
))
{
buddy_name
=
purple_buddy_get_name
(
buddy
);
titel
=
g_strdup_printf
(
_
(
"New message from %s"
),
buddy_name
);
chatty_notify_show_notification
(
titel
,
message
,
CHATTY_NOTIFY_MESSAGE_RECEIVED
,
conv
);
g_free
(
titel
);
}
if
(
*
message
!=
'\0'
)
{
// TODO
: LELAND:
UID to be implemented by XEP-0313
// TODO UID to be implemented by XEP-0313
chatty_utils_generate_uuid
(
&
uuid
);
who_no_resource
=
chatty_utils_jabber_id_strip
(
who
);
if
(
flags
&
PURPLE_MESSAGE_RECV
)
{
if
(
buddy
&&
purple_blist_node_get_bool
(
node
,
"chatty-notifications"
))
{
buddy_name
=
purple_buddy_get_alias
(
buddy
);
titel
=
g_strdup_printf
(
_
(
"New message from %s"
),
buddy_name
);
avatar
=
chatty_icon_get_buddy_icon
((
PurpleBlistNode
*
)
buddy
,
alias
,
CHATTY_ICON_SIZE_SMALL
,
chatty_blist_protocol_is_sms
(
account
)
?
CHATTY_COLOR_GREEN
:
CHATTY_COLOR_BLUE
,
FALSE
);
chatty_notify_show_notification
(
titel
,
message
,
CHATTY_NOTIFY_MESSAGE_RECEIVED
,
conv
,
avatar
);
g_object_unref
(
avatar
);
g_free
(
titel
);
}
chatty_msg_list_add_message
(
chatty_conv
->
msg_list
,
MSG_IS_INCOMING
,
message
,
group_chat
?
who
:
timestamp
,
icon
?
icon
:
NULL
);
if
(
type
==
PURPLE_CONV_TYPE_CHAT
){
chatty_history_add_chat_message
(
message
,
1
,
account
->
username
,
real_who
,
uuid
,
mtime
,
conv_name
);
}
else
{
...
...
@@ -2228,12 +2239,12 @@ chatty_conv_write_conversation (PurpleConversation *conv,
message
,
NULL
,
NULL
);
if
(
type
==
PURPLE_CONV_TYPE_CHAT
){
chatty_history_add_chat_message
(
message
,
-
1
,
account
->
username
,
real_who
,
uuid
,
mtime
,
conv_name
);
}
else
{
chatty_history_add_im_message
(
message
,
-
1
,
account
->
username
,
who_no_resource
,
uuid
,
mtime
);
}
}
else
if
(
flags
&
PURPLE_MESSAGE_SYSTEM
)
{
if
(
purple_blist_node_get_bool
(
node
,
"chatty-status-msg"
))
{
chatty_msg_list_add_message
(
chatty_conv
->
msg_list
,
...
...
src/chatty-folks.c
View file @
88fe69dd
...
...
@@ -206,6 +206,8 @@ cb_pixbuf_from_stream_ready (GObject *source_object,
AvatarData
*
data
=
avatar_data
;
PurpleContact
*
contact
;
PurpleBuddy
*
buddy
;
gchar
*
buffer
;
size_t
size
;
g_autoptr
(
GError
)
error
=
NULL
;
...
...
@@ -221,18 +223,18 @@ cb_pixbuf_from_stream_ready (GObject *source_object,
switch
(
data
->
mode
)
{
case
CHATTY_FOLKS_SET_CONTACT_ROW_ICON
:
g_return_if_fail
(
data
->
row
!=
NULL
);
g_object_set
(
data
->
row
,
"avatar"
,
chatty_icon_shape_pixbuf
(
pixbuf
),
NULL
);
break
;
case
CHATTY_FOLKS_SET_PURPLE_BUDDY_ICON
:
gdk_pixbuf_save
(
pixbuf
,
"/var/tmp/chatty_tmp.jpg"
,
"jpeg"
,
&
error
,
"quality"
,
"100"
,
NULL
);
gdk_pixbuf_save
_to_buffer
(
pixbuf
,
&
buffer
,
&
size
,
"png"
,
&
error
,
NULL
);
if
(
error
!=
NULL
)
{
g_error
(
"Could not save pixbuf to
file
: %s"
,
error
->
message
);
g_error
(
"Could not save pixbuf to
buffer
: %s"
,
error
->
message
);
g_slice_free
(
AvatarData
,
data
);
...
...
@@ -240,16 +242,11 @@ cb_pixbuf_from_stream_ready (GObject *source_object,
}
buddy
=
purple_find_buddy
(
data
->
purple_account
,
data
->
purple_user_name
);
contact
=
purple_buddy_get_contact
(
buddy
);
purple_buddy_icons_node_set_custom_icon_from_file
((
PurpleBlistNode
*
)
contact
,
"/var/tmp/chatty_tmp.jpg"
);
if
(
remove
(
"/var/tmp/chatty_tmp.jpg"
))
{
g_error
(
"Could not delete file: %s"
,
"/var/tmp/chatty_tmp.jpg"
);
};
purple_buddy_icons_node_set_custom_icon
((
PurpleBlistNode
*
)
contact
,
(
guchar
*
)
buffer
,
size
);
break
;
default:
...
...
src/chatty-icons.c
View file @
88fe69dd
...
...
@@ -379,3 +379,31 @@ chatty_icon_do_alphashift (GdkPixbuf *pixbuf,
pixels
+=
padding
;
}
}
GIcon
*
chatty_icon_get_gicon_from_pixbuf
(
GdkPixbuf
*
pixbuf
)
{
GIcon
*
icon
;
GBytes
*
bytes
;
gchar
*
buffer
;
gsize
size
;
g_autoptr
(
GError
)
error
=
NULL
;
gdk_pixbuf_save_to_buffer
(
pixbuf
,
&
buffer
,
&
size
,
"png"
,
&
error
,
NULL
);
if
(
error
!=
NULL
)
{
g_error
(
"%s Could not save pixbuf to buffer: %s"
,
__func__
,
error
->
message
);
return
NULL
;
}
bytes
=
g_bytes_new
(
buffer
,
size
);
icon
=
g_bytes_icon_new
(
bytes
);
g_free
(
buffer
);
g_bytes_unref
(
bytes
);
return
icon
;
}
src/chatty-icons.h
View file @
88fe69dd
...
...
@@ -27,6 +27,7 @@ typedef enum
void
chatty_icon_do_alphashift
(
GdkPixbuf
*
pixbuf
,
int
shift
);
GdkPixbuf
*
chatty_icon_shape_pixbuf
(
GdkPixbuf
*
pixbuf
);
GIcon
*
chatty_icon_get_gicon_from_pixbuf
(
GdkPixbuf
*
pixbuf
);
GdkPixbuf
*
chatty_icon_get_buddy_icon
(
PurpleBlistNode
*
node
,
const
char
*
name
,
...
...
src/chatty-notify.c
View file @
88fe69dd
...
...
@@ -11,6 +11,7 @@
#include "purple.h"
#include "chatty-window.h"
#include "chatty-notify.h"
#include "chatty-icons.h"
#include "chatty-conversation.h"
static
PurpleConversation
*
conv_notify
=
NULL
;
...
...
@@ -45,7 +46,8 @@ void
chatty_notify_show_notification
(
const
char
*
title
,
const
char
*
message
,
guint
notification_type
,
PurpleConversation
*
conv
)
PurpleConversation
*
conv
,
GdkPixbuf
*
pixbuf
)
{
GApplication
*
application
;
GNotification
*
notification
;
...
...
@@ -59,14 +61,14 @@ chatty_notify_show_notification (const char *title,
notification
=
g_notification_new
(
"chatty"
);
g_notification_set_body
(
notification
,
message
);
icon
=
g_icon_new_for_string
(
"sm.puri.Chatty-symbolic"
,
NULL
);
if
(
pixbuf
)
{
icon
=
chatty_icon_get_gicon_from_pixbuf
(
pixbuf
);
if
(
icon
)
{
g_notification_set_icon
(
notification
,
icon
);
}
g_notification_set_body
(
notification
,
message
);
switch
(
notification_type
)
{
case
CHATTY_NOTIFY_MESSAGE_RECEIVED
:
g_notification_add_button
(
notification
,
...
...
src/chatty-notify.h
View file @
88fe69dd
...
...
@@ -22,6 +22,7 @@ enum {
void
chatty_notify_show_notification
(
const
char
*
title
,
const
char
*
message
,
guint
notification_type
,
PurpleConversation
*
conv
);
PurpleConversation
*
conv
,
GdkPixbuf
*
pixbuf
);
#endif
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