Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
ximper-shell-notification-center
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ximper Linux
ximper-shell-notification-center
Commits
929d0d54
Unverified
Commit
929d0d54
authored
Dec 15, 2023
by
Erik Reider
Committed by
GitHub
Dec 15, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add border-radius property to notification images (#353)
parent
2d87e229
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
24 deletions
+41
-24
style.scss
data/style/style.scss
+1
-0
mpris_player.vala
src/controlCenter/widgets/mpris/mpris_player.vala
+5
-1
functions.vala
src/functions.vala
+22
-21
notification.vala
src/notification/notification.vala
+13
-2
No files found.
data/style/style.scss
View file @
929d0d54
...
...
@@ -98,6 +98,7 @@
.image
{
/* Notification Primary Image */
-gtk-icon-effect
:
none
;
border-radius
:
10px
;
/* Size in px */
}
.summary
{
/* Notification summary/title */
...
...
src/controlCenter/widgets/mpris/mpris_player.vala
View file @
929d0d54
...
...
@@ -262,11 +262,15 @@ namespace SwayNotificationCenter.Widgets.Mpris {
source
.
media_player
.
identity
);
}
if
(
pixbuf
!=
null
)
{
pixbuf
=
Functions
.
scale_round_pixbuf
(
pixbuf
,
var
surface
=
Functions
.
scale_round_pixbuf
(
pixbuf
,
mpris_config
.
image_size
,
mpris_config
.
image_size
,
scale
,
mpris_config
.
image_radius
);
pixbuf
=
Gdk
.
pixbuf_get_from_surface
(
surface
,
0
,
0
,
mpris_config
.
image_size
,
mpris_config
.
image_size
);
album_art
.
set_from_pixbuf
(
pixbuf
);
album_art
.
get_style_context
().
set_scale
(
1
);
return
;
...
...
src/functions.vala
View file @
929d0d54
...
...
@@ -17,21 +17,19 @@ namespace SwayNotificationCenter {
public
static
void
set_image_path
(
owned
string
path
,
Gtk
.
Image
img
,
int
icon_size
,
int
radius
,
bool
file_exists
)
{
if
((
path
.
length
>
6
&&
path
.
slice
(
0
,
7
)
==
"file://"
)
||
file_exists
)
{
// Try as a URI (file:// is the only URI schema supported right now)
try
{
if
(!
file_exists
)
path
=
path
.
slice
(
7
,
path
.
length
);
var
pixbuf
=
new
Gdk
.
Pixbuf
.
from_file_at_scale
(
path
,
icon_size
*
img
.
scale_factor
,
icon_size
*
img
.
scale_factor
,
true
);
var
surface
=
Gdk
.
cairo_surface_create_from_pixbuf
(
pixbuf
,
img
.
scale_factor
,
img
.
get_window
());
var
pixbuf
=
new
Gdk
.
Pixbuf
.
from_file
(
path
);
var
surface
=
scale_round_pixbuf
(
pixbuf
,
icon_size
,
icon_size
,
img
.
scale_factor
,
radius
);
img
.
set_from_surface
(
surface
);
return
;
}
catch
(
Error
e
)
{
...
...
@@ -43,7 +41,10 @@ namespace SwayNotificationCenter {
}
}
public
static
void
set_image_data
(
ImageData
data
,
Gtk
.
Image
img
,
int
icon_size
)
{
public
static
void
set_image_data
(
ImageData
data
,
Gtk
.
Image
img
,
int
icon_size
,
int
radius
)
{
// Rebuild and scale the image
var
pixbuf
=
new
Gdk
.
Pixbuf
.
with_unowned_data
(
data
.
data
,
Gdk
.
Colorspace
.
RGB
,
...
...
@@ -54,14 +55,11 @@ namespace SwayNotificationCenter {
data
.
rowstride
,
null
);
pixbuf
=
pixbuf
.
scale_simple
(
icon_size
*
img
.
scale_factor
,
icon_size
*
img
.
scale_factor
,
Gdk
.
InterpType
.
BILINEAR
);
var
surface
=
Gdk
.
cairo_surface_create_from_pixbuf
(
pixbuf
,
img
.
scale_factor
,
img
.
get_window
());
var
surface
=
scale_round_pixbuf
(
pixbuf
,
icon_size
,
icon_size
,
img
.
scale_factor
,
radius
);
img
.
set_from_surface
(
surface
);
}
...
...
@@ -212,11 +210,14 @@ namespace SwayNotificationCenter {
}
/** Scales the pixbuf to fit the given dimensions */
public
static
Gdk
.
Pixbuf
scale_round_pixbuf
(
Gdk
.
Pixbuf
pixbuf
,
public
static
Cairo
.
Surface
scale_round_pixbuf
(
Gdk
.
Pixbuf
pixbuf
,
int
buffer_width
,
int
buffer_height
,
int
img_scale
,
int
radius
)
{
// Limit radii size
radius
=
int
.
min
(
radius
,
int
.
min
(
buffer_width
/
2
,
buffer_height
/
2
));
Cairo
.
Surface
surface
=
new
Cairo
.
ImageSurface
(
Cairo
.
Format
.
ARGB32
,
buffer_width
,
buffer_height
);
...
...
@@ -230,7 +231,7 @@ namespace SwayNotificationCenter {
cr
.
arc
(
radius
,
buffer_height
-
radius
,
radius
,
90
*
DEGREES
,
180
*
DEGREES
);
cr
.
arc
(
radius
,
radius
,
radius
,
180
*
DEGREES
,
270
*
DEGREES
);
cr
.
close_path
();
cr
.
set_source_rgb
(
0
,
0
,
0
);
cr
.
set_source_rgb
a
(
0
,
0
,
0
,
0
);
cr
.
clip
();
cr
.
paint
();
...
...
@@ -261,7 +262,7 @@ namespace SwayNotificationCenter {
cr
.
restore
();
scale_surf
.
finish
();
return
Gdk
.
pixbuf_get_from_surface
(
surface
,
0
,
0
,
buffer_width
,
buffer_height
)
;
return
surface
;
}
private
static
void
draw_scale_tall
(
int
buffer_width
,
...
...
src/notification/notification.vala
View file @
929d0d54
...
...
@@ -668,22 +668,33 @@ namespace SwayNotificationCenter {
var
app_icon_exists
=
File
.
new_for_path
(
param
.
app_icon
??
""
).
query_exists
();
// Get the image CSS corner radius in pixels
int
radius
=
0
;
unowned
var
ctx
=
img
.
get_style_context
();
var
value
=
ctx
.
get_property
(
Gtk
.
STYLE_PROPERTY_BORDER_RADIUS
,
ctx
.
get_state
());
if
(
value
.
type
()
==
Type
.
INT
)
{
radius
=
value
.
get_int
();
}
if
(
param
.
image_data
.
is_initialized
)
{
Functions
.
set_image_data
(
param
.
image_data
,
img
,
notification_icon_size
);
notification_icon_size
,
radius
);
}
else
if
(
param
.
image_path
!=
null
&&
param
.
image_path
!=
""
&&
img_path_exists
)
{
Functions
.
set_image_path
(
param
.
image_path
,
img
,
notification_icon_size
,
radius
,
img_path_exists
);
}
else
if
(
param
.
app_icon
!=
null
&&
param
.
app_icon
!=
""
)
{
Functions
.
set_image_path
(
param
.
app_icon
,
img
,
notification_icon_size
,
radius
,
app_icon_exists
);
}
else
if
(
param
.
icon_data
.
is_initialized
)
{
Functions
.
set_image_data
(
param
.
icon_data
,
img
,
notification_icon_size
);
notification_icon_size
,
radius
);
}
if
(
img
.
storage_type
==
Gtk
.
ImageType
.
EMPTY
)
{
...
...
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