Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
alacarte
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
GNOME
alacarte
Commits
ae6b92da
Commit
ae6b92da
authored
5 years ago
by
Alberts Muktupāvels
Browse files
Options
Downloads
Patches
Plain Diff
ItemEditor: load icon file in correct size
https://gitlab.gnome.org/GNOME/alacarte/-/issues/4
parent
46a7d0d1
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Alacarte/ItemEditor.py
+21
-3
21 additions, 3 deletions
Alacarte/ItemEditor.py
with
21 additions
and
3 deletions
Alacarte/ItemEditor.py
+
21
−
3
View file @
ae6b92da
...
...
@@ -16,11 +16,12 @@
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import
cairo
import
gettext
import
os
import
gi
gi
.
require_version
(
'
Gtk
'
,
'
3.0
'
)
from
gi.repository
import
GLib
,
GObject
,
Gtk
from
gi.repository
import
GLib
,
GObject
,
Gtk
,
Gdk
,
GdkPixbuf
from
Alacarte
import
config
,
util
_
=
gettext
.
gettext
...
...
@@ -66,9 +67,26 @@ def strip_extensions(icon):
else
:
return
icon
def
set_icon_file
(
image
,
file_name
):
scale
=
image
.
get_scale_factor
()
size
=
64
*
scale
pixbuf
=
GdkPixbuf
.
Pixbuf
.
new_from_file_at_size
(
file_name
,
size
,
size
)
surface
=
cairo
.
ImageSurface
(
cairo
.
FORMAT_ARGB32
,
size
,
size
)
context
=
cairo
.
Context
(
surface
)
Gdk
.
cairo_set_source_pixbuf
(
context
,
pixbuf
,
(
size
-
pixbuf
.
get_width
())
/
2
,
(
size
-
pixbuf
.
get_height
())
/
2
)
context
.
paint
()
surface
.
set_device_scale
(
scale
,
scale
)
image
.
props
.
surface
=
surface
def
set_icon_string
(
image
,
icon
):
if
GLib
.
path_is_absolute
(
icon
):
image
.
props
.
file
=
icon
set_icon_file
(
image
,
icon
)
else
:
image
.
props
.
icon_name
=
strip_extensions
(
icon
)
...
...
@@ -89,7 +107,7 @@ class IconPicker(object):
Gtk
.
STOCK_OK
,
Gtk
.
ResponseType
.
ACCEPT
))
response
=
chooser
.
run
()
if
response
==
Gtk
.
ResponseType
.
ACCEPT
:
se
lf
.
image
.
props
.
file
=
chooser
.
get_filename
()
se
t_icon_file
(
self
.
image
,
chooser
.
get_filename
()
)
chooser
.
destroy
()
class
ItemEditor
(
GObject
.
GObject
):
...
...
This diff is collapsed.
Click to expand it.
Alberts Muktupāvels
@muktupavels
mentioned in commit
9942022c
·
3 years ago
mentioned in commit
9942022c
mentioned in commit 9942022c3df2d994e4178eae4e251e74a077dc26
Toggle commit list
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