Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Icon Library
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
10
Issues
10
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
World
Design Tooling
Icon Library
Commits
e4fc94fe
Commit
e4fc94fe
authored
Jul 23, 2019
by
Bilal Elmoussaoui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Export: copy the icon as an SVG
parent
0c63b14b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
4 deletions
+22
-4
src/widgets/export.rs
src/widgets/export.rs
+22
-4
No files found.
src/widgets/export.rs
View file @
e4fc94fe
...
...
@@ -15,6 +15,9 @@ pub struct ExportDialog {
icon_size_64
:
gtk
::
Image
,
}
const
TARGET_SVG
:
u32
=
0
;
const
TARGET_SVG_XML
:
u32
=
1
;
impl
ExportDialog
{
pub
fn
new
(
icon
:
&
Icon
)
->
ExportDialog
{
let
builder
=
gtk
::
Builder
::
new_from_resource
(
"/org/gnome/design/IconLibrary/export_dialog.ui"
);
...
...
@@ -96,15 +99,30 @@ impl ExportDialog {
// Copy icon to clipboard action: copy-clipboard
let
icon_name
=
icon
.name
.clone
();
let
copy_icon
=
gio
::
SimpleAction
::
new
(
"copy-clipboard"
,
None
);
copy_icon
.connect_activate
(
move
|
_
,
_
|
{
let
display
=
gdk
::
Display
::
get_default
()
.unwrap
();
let
clipboard
=
gtk
::
Clipboard
::
get_default
(
&
display
)
.unwrap
();
let
theme
=
gtk
::
IconTheme
::
get_default
()
.unwrap
();
let
pixbuf
=
theme
.load_icon
(
&
icon_name
,
16
,
gtk
::
IconLookupFlags
::
FORCE_SYMBOLIC
)
.unwrap
();
let
svg_target
=
gtk
::
TargetEntry
::
new
(
"image/svg"
,
gtk
::
TargetFlags
::
OTHER_APP
,
TARGET_SVG
);
let
svg_xml_target
=
gtk
::
TargetEntry
::
new
(
"image/svg+xml"
,
gtk
::
TargetFlags
::
OTHER_APP
,
TARGET_SVG_XML
);
let
targets
=
[
svg_target
,
svg_xml_target
];
clipboard
.set_text
(
""
);
clipboard
.set_image
(
&
pixbuf
.unwrap
());
let
icon_name
=
icon_name
.clone
();
let
svg_targets
=
targets
.clone
();
clipboard
.set_with_data
(
&
targets
,
move
|
_
,
selection_data
,
target_id
|
{
if
[
TARGET_SVG
,
TARGET_SVG_XML
]
.contains
(
&
target_id
)
{
// load the svg content
let
theme
=
gtk
::
IconTheme
::
get_default
()
.unwrap
();
let
icon_info
=
theme
.lookup_icon
(
&
icon_name
,
16
,
gtk
::
IconLookupFlags
::
FORCE_SYMBOLIC
)
.unwrap
();
let
icon_path
=
icon_info
.get_filename
()
.unwrap
();
let
icon_file
=
gio
::
File
::
new_for_path
(
icon_path
);
let
svg
=
icon_file
.load_contents
(
Some
(
&
gio
::
Cancellable
::
new
()))
.unwrap
();
// copy the svg content to clipboard when requested
let
target
=
svg_targets
.get
(
target_id
as
usize
)
.unwrap
()
.get_target
();
selection_data
.set
(
&
gdk
::
Atom
::
intern
(
target
),
8
,
&
svg
.0
);
}
});
});
actions
.add_action
(
&
copy_icon
);
...
...
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