-
-
Notifications
You must be signed in to change notification settings - Fork 90
library: Add libportal screenshot entry #208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
So this is working fine for me but
For @SoNiC-HeRE - on the same OS (Fedora 37) - I'm investigating what it could be. |
Allows for split view and navigating entries easily
|
The error has been resolved but when i click the button nothing happens |
05f69f1 to
55e450f
Compare
|
@SoNiC-HeRE I merged Perhaps check Workbench permissions |
|
Sure, I'll check again |
Works fine now, had to install it seperately to check, probably was missing some sort of permission when run directly from builder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 more things
Please use Gio._promisify
Can you check if you get an error if the permission is denied? If so we can display a message using Adw.MessageDialog telling the user how to fix it (I'll let you come up with a clear and concise sentence).
src/Library/demos/Screenshot/main.js
Outdated
| const { GdkPixbuf, Gio, GLib, GObject, Gst, Gtk, Pango, PangoCairo } = | ||
| imports.gi; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use import x from y
src/Library/Library.blp
Outdated
| Adw.PreferencesGroup library_portal { | ||
| title: "User Interface"; | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe
| Adw.PreferencesGroup library_portal { | |
| title: "User Interface"; | |
| } | |
| Adw.PreferencesGroup library_desktop { | |
| title: "Desktop APIs"; | |
| } |
we can move Notifications there later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, even better (but it's mobile too)
| Adw.PreferencesGroup library_portal { | |
| title: "User Interface"; | |
| } | |
| Adw.PreferencesGroup library_platform { | |
| title: "Platform APIs"; | |
| } | |
|
|
||
| Adw.StatusPage { | ||
| title: "Screenshot"; | ||
| description: _("Keep a snapshot of your current screen"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should address the developer, not the end user.
| description: _("Keep a snapshot of your current screen"); | |
| description: _("Take a picture of the screen"); |
|
|
||
| Button Screenshot { | ||
| icon-name: "camera"; | ||
| margin-bottom: 40; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use multiples of 6
| margin-bottom: 40; | |
| margin-bottom: 42; |
|
|
||
| LinkButton { | ||
| label: "API Reference"; | ||
| uri: "https://libportal.org/"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| uri: "https://libportal.org/"; | |
| uri: "https://libportal.org/method.Portal.take_screenshot.html"; |
src/Library/demos/Screenshot/main.js
Outdated
| }); | ||
| } | ||
|
|
||
| Screenshot.connect("clicked", _takeScreenshot); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Screenshot.connect("clicked", _takeScreenshot); | |
| button.connect("clicked", takeScreenshot); |
| { | ||
| "name": "Screenshot", | ||
| "category": "portal", | ||
| "description": "Keep a snapshot of your current screen", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| "description": "Keep a snapshot of your current screen", | |
| "description": "Take a picture of the screen", |
| @@ -0,0 +1,10 @@ | |||
| { | |||
| "name": "Screenshot", | |||
| "category": "portal", | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| "category": "portal", | |
| "category": "desktop", |
| "category": "portal", | ||
| "description": "Keep a snapshot of your current screen", | ||
| "panels": [ | ||
| "ui", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| "ui", | |
| "code", |
it's more important here
src/Library/demos/Screenshot/main.js
Outdated
| const pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale( | ||
| path, | ||
| 60, | ||
| 40, | ||
| true, | ||
| ); | ||
| workbench.builder.get_object("picture").set_pixbuf(pixbuf); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hehe thankefully we don't need pixbuf and scale to arbitrary dimensions (which don't work equally well for differentt display rattios)
take_screenshot gives us a file:/// uri, which we can use to load the file directly into Picture
const uri = ...
const file = Gio.File.new_for_uri(uri);
picture.set_file(file);
|
@sonnyp The portal methods doesnt seem to work properly with GIO's async methods. Tried implementing without using Gio._promisify Also i thought It'd be better if we could directly log the error message instead of Adw.messagedialog wdyt? |
What is the error? What's not working? I can take a look.
The MessageDialog is not for showing the error, it's to tell the user what to do if the permission is/was denied. If error is permission denied: show a MessageDialog to tel the user what todo |
I'll try fixing again , if not i'll share |
|
All of the above mentioned changes have been implemented. Implemented with Async method as well but works fine even without it. Thought code would be shorter and cleaner. |
sonnyp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good error handling 👍
An issue I noticed while testing the demo is that the size and position of elements change once the screenshot is taken and displayed. It doesn't feel great.
I have fixed that, made promisify work and address the last comments in this commit: 0f22390
Please fetch Workbench main and look at my changes and the result.
| icon-name: "screenshooter-symbolic"; | ||
| margin-bottom: 42; | ||
| width-request: 6; | ||
| height-request: 48; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't override stanard elements default allocation (size).
Also, I think a label button would be clearer. No need for small icon button.
src/Library/demos/Screenshot/main.js
Outdated
| const portal = new Xdp.Portal(); | ||
| const parent = XdpGtk.parent_new_gtk(workbench.window); | ||
| const picture = workbench.builder.get_object("picture"); | ||
| const window = button.get_ancestor(Gtk.Window); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's workbench.window
src/Library/demos/Screenshot/main.js
Outdated
| const button = workbench.builder.get_object("button"); | ||
| const portal = new Xdp.Portal(); | ||
| const parent = XdpGtk.parent_new_gtk(workbench.window); | ||
| const picture = workbench.builder.get_object("picture"); | ||
| const window = button.get_ancestor(Gtk.Window); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try to group things that make sense together
src/Library/demos/Screenshot/main.js
Outdated
| picture.width_request = 180; | ||
| picture.height_request = 180; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remember to use properties in Bluepint when possible
Sure, I'll have a look |


Added Screenshot Demo in a new section Portal under Library
Issue workbenchdev/demos#3