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
735f2c5a
Commit
735f2c5a
authored
May 31, 2022
by
Erik Reider
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add notification-image-size property to config
parent
725b80c6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
44 additions
and
14 deletions
+44
-14
config.json.in
src/config.json.in
+1
-0
configModel.vala
src/configModel/configModel.vala
+16
-0
configSchema.json
src/configSchema.json
+6
-0
functions.vala
src/functions.vala
+6
-5
notification.ui
src/notification/notification.ui
+1
-1
notification.vala
src/notification/notification.vala
+14
-8
No files found.
src/config.json.in
View file @
735f2c5a
...
...
@@ -6,6 +6,7 @@
"control-center-margin-bottom": 0,
"control-center-margin-right": 0,
"control-center-margin-left": 0,
"notification-icon-size": 64,
"timeout": 10,
"timeout-low": 5,
"timeout-critical": 0,
...
...
src/configModel/configModel.vala
View file @
735f2c5a
...
...
@@ -453,6 +453,22 @@ namespace SwayNotificationCenter {
}
}
/**
* Notification icon size, in pixels.
*/
private
const
int
NOTIFICATION_ICON_MINIMUM_SIZE
=
16
;
private
const
int
NOTIFICATION_ICON_DEFAULT_SIZE
=
64
;
private
int
_notification_icon_size
=
NOTIFICATION_ICON_DEFAULT_SIZE
;
public
int
notification_icon_size
{
get
{
return
_notification_icon_size
;
}
set
{
_notification_icon_size
=
value
>
NOTIFICATION_ICON_MINIMUM_SIZE
?
value
:
NOTIFICATION_ICON_MINIMUM_SIZE
;
}
}
/* Methods */
/**
...
...
src/configSchema.json
View file @
735f2c5a
...
...
@@ -39,6 +39,12 @@
"description"
:
"The margin (in pixels) at the left of the notification center. 0 to disable"
,
"default"
:
0
},
"notification-icon-size"
:
{
"type"
:
"integer"
,
"description"
:
"The notification icon size (in pixels)"
,
"default"
:
64
,
"minimum"
:
16
},
"timeout"
:
{
"type"
:
"integer"
,
"description"
:
"The notification timeout for notifications with normal priority"
,
...
...
src/functions.vala
View file @
735f2c5a
...
...
@@ -2,6 +2,7 @@ namespace SwayNotificationCenter {
public
class
Functions
{
public
static
void
set_image_path
(
owned
string
path
,
Gtk
.
Image
img
,
int
icon_size
,
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)
...
...
@@ -10,8 +11,8 @@ namespace SwayNotificationCenter {
var
pixbuf
=
new
Gdk
.
Pixbuf
.
from_file_at_scale
(
path
,
Notification
.
icon_image
_size
*
img
.
scale_factor
,
Notification
.
icon_image
_size
*
img
.
scale_factor
,
icon
_size
*
img
.
scale_factor
,
icon
_size
*
img
.
scale_factor
,
true
);
var
surface
=
Gdk
.
cairo_surface_create_from_pixbuf
(
pixbuf
,
...
...
@@ -32,7 +33,7 @@ namespace SwayNotificationCenter {
}
}
public
static
void
set_image_data
(
ImageData
data
,
Gtk
.
Image
img
)
{
public
static
void
set_image_data
(
ImageData
data
,
Gtk
.
Image
img
,
int
icon_size
)
{
// Rebuild and scale the image
var
pixbuf
=
new
Gdk
.
Pixbuf
.
with_unowned_data
(
data
.
data
,
Gdk
.
Colorspace
.
RGB
,
...
...
@@ -44,8 +45,8 @@ namespace SwayNotificationCenter {
null
);
pixbuf
=
pixbuf
.
scale_simple
(
Notification
.
icon_image
_size
*
img
.
scale_factor
,
Notification
.
icon_image
_size
*
img
.
scale_factor
,
icon
_size
*
img
.
scale_factor
,
icon
_size
*
img
.
scale_factor
,
Gdk
.
InterpType
.
BILINEAR
);
var
surface
=
Gdk
.
cairo_surface_create_from_pixbuf
(
pixbuf
,
...
...
src/notification/notification.ui
View file @
735f2c5a
...
...
@@ -63,7 +63,7 @@
<object
class=
"GtkImage"
id=
"img"
>
<property
name=
"visible"
>
True
</property>
<property
name=
"can-focus"
>
False
</property>
<property
name=
"valign"
>
start
</property>
<property
name=
"valign"
>
center
</property>
<property
name=
"margin-end"
>
12
</property>
<property
name=
"icon_size"
>
6
</property>
<style>
...
...
src/notification/notification.vala
View file @
735f2c5a
...
...
@@ -37,7 +37,7 @@ namespace SwayNotificationCenter {
unowned
Gtk
.
Image
body_image
;
public
static
Gtk
.
IconSize
icon_size
=
Gtk
.
IconSize
.
INVALID
;
p
ublic
static
int
icon_image_size
=
64
;
p
rivate
int
notification_icon_size
{
get
;
default
=
ConfigModel
.
instance
.
notification_icon_size
;
}
private
uint
timeout_id
=
0
;
...
...
@@ -402,9 +402,9 @@ namespace SwayNotificationCenter {
return
;
}
img
.
set_pixel_size
(
Notification
.
icon_image
_size
);
img
.
height_request
=
Notification
.
icon_image
_size
;
img
.
width_request
=
Notification
.
icon_image
_size
;
img
.
set_pixel_size
(
notification_icon
_size
);
img
.
height_request
=
notification_icon
_size
;
img
.
width_request
=
notification_icon
_size
;
var
img_path_exists
=
File
.
new_for_path
(
param
.
image_path
??
""
).
query_exists
();
...
...
@@ -412,15 +412,21 @@ namespace SwayNotificationCenter {
param
.
app_icon
??
""
).
query_exists
();
if
(
param
.
image_data
.
is_initialized
)
{
Functions
.
set_image_data
(
param
.
image_data
,
img
);
Functions
.
set_image_data
(
param
.
image_data
,
img
,
notification_icon_size
);
}
else
if
(
param
.
image_path
!=
null
&&
param
.
image_path
!=
""
&&
img_path_exists
)
{
Functions
.
set_image_path
(
param
.
image_path
,
img
,
img_path_exists
);
Functions
.
set_image_path
(
param
.
image_path
,
img
,
notification_icon_size
,
img_path_exists
);
}
else
if
(
param
.
app_icon
!=
null
&&
param
.
app_icon
!=
""
)
{
Functions
.
set_image_path
(
param
.
app_icon
,
img
,
app_icon_exists
);
Functions
.
set_image_path
(
param
.
app_icon
,
img
,
notification_icon_size
,
app_icon_exists
);
}
else
if
(
param
.
icon_data
.
is_initialized
)
{
Functions
.
set_image_data
(
param
.
icon_data
,
img
);
Functions
.
set_image_data
(
param
.
icon_data
,
img
,
notification_icon_size
);
}
else
{
// Get the app icon
GLib
.
Icon
?
icon
=
null
;
...
...
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