Skip to content

Commit 32bf8b8

Browse files
committed
fmt
1 parent da8da5c commit 32bf8b8

10 files changed

+329
-265
lines changed

.editorconfig

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
indent_size = 4
5+
indent_style = tab
6+
end_of_line = lf
7+
charset = utf-8
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<component type="desktop-application">
3-
<id>org.shutter-project.Shutter</id>
4-
<name>Shutter</name>
5-
<summary>The feature-rich screenshot tool</summary>
6-
<launchable type="desktop-id">org.shutter-project.Shutter.desktop</launchable>
7-
<metadata_license>CC0-1.0</metadata_license>
8-
<project_license>GPL-3.0+</project_license>
9-
<description>
10-
<p>
11-
Shutter is a feature-rich screenshot program. You can take a screenshot of a
12-
specific area, window, your whole screen, or even of a website - apply different
13-
effects to it, draw on it to highlight points, and then upload to an image
14-
hosting site, all within one window.
15-
</p>
16-
<p>
17-
Shutter allows you to capture nearly anything on your screen without losing
18-
control over your screenshots (tabbed interface).
19-
You don't need to open an external graphics editor like GIMP, because Shutter
20-
ships with its own built-in editor.
21-
</p>
22-
</description>
23-
<url type="homepage">https://shutter-project.org/</url>
24-
<url type="bugtracker">https://github.com/shutter-project/shutter/issues</url>
25-
<url type="contact">https://shutter-project.org/contact/</url>
26-
<screenshots>
27-
<screenshot type="default">
28-
<image>https://shutter-project.org/wp-content/uploads/key_feature_030.png</image>
29-
</screenshot>
30-
<screenshot>
31-
<image>https://shutter-project.org/wp-content/uploads/key_feature_042.png</image>
32-
</screenshot>
33-
<screenshot>
34-
<image>https://shutter-project.org/wp-content/uploads/key_feature_036.png</image>
35-
</screenshot>
36-
<screenshot>
37-
<image>https://shutter-project.org/wp-content/uploads/key_feature_073.png</image>
38-
</screenshot>
39-
</screenshots>
3+
<id>org.shutter-project.Shutter</id>
4+
<name>Shutter</name>
5+
<summary>The feature-rich screenshot tool</summary>
6+
<launchable type="desktop-id">org.shutter-project.Shutter.desktop</launchable>
7+
<metadata_license>CC0-1.0</metadata_license>
8+
<project_license>GPL-3.0+</project_license>
9+
<description>
10+
<p>
11+
Shutter is a feature-rich screenshot program. You can take a screenshot of a
12+
specific area, window, your whole screen, or even of a website - apply different
13+
effects to it, draw on it to highlight points, and then upload to an image
14+
hosting site, all within one window.
15+
</p>
16+
<p>
17+
Shutter allows you to capture nearly anything on your screen without losing
18+
control over your screenshots (tabbed interface).
19+
You don't need to open an external graphics editor like GIMP, because Shutter
20+
ships with its own built-in editor.
21+
</p>
22+
</description>
23+
<url type="homepage">https://shutter-project.org/</url>
24+
<url type="bugtracker">https://github.com/shutter-project/shutter/issues</url>
25+
<url type="contact">https://shutter-project.org/contact/</url>
26+
<screenshots>
27+
<screenshot type="default">
28+
<image>https://shutter-project.org/wp-content/uploads/key_feature_030.png</image>
29+
</screenshot>
30+
<screenshot>
31+
<image>https://shutter-project.org/wp-content/uploads/key_feature_042.png</image>
32+
</screenshot>
33+
<screenshot>
34+
<image>https://shutter-project.org/wp-content/uploads/key_feature_036.png</image>
35+
</screenshot>
36+
<screenshot>
37+
<image>https://shutter-project.org/wp-content/uploads/key_feature_073.png</image>
38+
</screenshot>
39+
</screenshots>
4040
</component>

rustfmt.toml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
edition = "2024"
2+
hard_tabs = true
3+
normalize_doc_attributes = true
4+
overflow_delimited_expr = true
5+
reorder_impl_items = true

src/application.rs

+110-75
Original file line numberDiff line numberDiff line change
@@ -19,99 +19,134 @@
1919
*/
2020

2121
use adw::prelude::AdwDialogExt;
22-
use gtk::prelude::*;
2322
use adw::subclass::prelude::*;
23+
use gtk::prelude::*;
2424
use gtk::{gio, glib};
2525

26-
use crate::config::VERSION;
2726
use crate::ShutterWindow;
27+
use crate::config::VERSION;
2828

2929
mod imp {
30-
use super::*;
30+
use super::*;
31+
32+
#[derive(Debug, Default)]
33+
pub struct ShutterApplication {}
3134

32-
#[derive(Debug, Default)]
33-
pub struct ShutterApplication {}
35+
#[glib::object_subclass]
36+
impl ObjectSubclass for ShutterApplication {
37+
type ParentType = adw::Application;
38+
type Type = super::ShutterApplication;
3439

35-
#[glib::object_subclass]
36-
impl ObjectSubclass for ShutterApplication {
37-
const NAME: &'static str = "ShutterApplication";
38-
type Type = super::ShutterApplication;
39-
type ParentType = adw::Application;
40-
}
40+
const NAME: &'static str = "ShutterApplication";
41+
}
4142

42-
impl ObjectImpl for ShutterApplication {
43-
fn constructed(&self) {
44-
self.parent_constructed();
45-
let obj = self.obj();
46-
obj.setup_gactions();
47-
obj.set_accels_for_action("app.quit", &["<primary>q"]);
48-
}
49-
}
43+
impl ObjectImpl for ShutterApplication {
44+
fn constructed(&self) {
45+
self.parent_constructed();
46+
let obj = self.obj();
47+
obj.setup_gactions();
48+
obj.set_accels_for_action("app.quit", &["<primary>q"]);
49+
}
50+
}
5051

51-
impl ApplicationImpl for ShutterApplication {
52-
// We connect to the activate callback to create a window when the application
53-
// has been launched. Additionally, this callback notifies us when the user
54-
// tries to launch a "second instance" of the application. When they try
55-
// to do that, we'll just present any existing window.
56-
fn activate(&self) {
57-
let application = self.obj();
58-
// Get the current window or create one if necessary
59-
let window = if let Some(window) = application.active_window() {
60-
window
61-
} else {
62-
let window = ShutterWindow::new(&*application);
63-
window.upcast()
64-
};
52+
impl ApplicationImpl for ShutterApplication {
53+
// We connect to the activate callback to create a window when the application
54+
// has been launched. Additionally, this callback notifies us when the user
55+
// tries to launch a "second instance" of the application. When they try
56+
// to do that, we'll just present any existing window.
57+
fn activate(&self) {
58+
let application = self.obj();
59+
// Get the current window or create one if necessary
60+
let window = if let Some(window) = application.active_window() {
61+
window
62+
} else {
63+
let window = ShutterWindow::new(&*application);
64+
window.upcast()
65+
};
6566

66-
// Ask the window manager/compositor to present the window
67-
window.present();
68-
}
69-
}
67+
// Ask the window manager/compositor to present the window
68+
window.present();
69+
}
70+
}
7071

71-
impl GtkApplicationImpl for ShutterApplication {}
72-
impl AdwApplicationImpl for ShutterApplication {}
73-
}
72+
impl GtkApplicationImpl for ShutterApplication {}
73+
impl AdwApplicationImpl for ShutterApplication {}
74+
}
7475

7576
glib::wrapper! {
76-
pub struct ShutterApplication(ObjectSubclass<imp::ShutterApplication>)
77-
@extends gio::Application, gtk::Application, adw::Application,
78-
@implements gio::ActionGroup, gio::ActionMap;
77+
pub struct ShutterApplication(ObjectSubclass<imp::ShutterApplication>)
78+
@extends gio::Application, gtk::Application, adw::Application,
79+
@implements gio::ActionGroup, gio::ActionMap;
7980
}
8081

8182
impl ShutterApplication {
82-
pub fn new(application_id: &str, flags: &gio::ApplicationFlags) -> Self {
83-
glib::Object::builder()
84-
.property("application-id", application_id)
85-
.property("flags", flags)
86-
.build()
87-
}
83+
pub fn new(application_id: &str, flags: &gio::ApplicationFlags) -> Self {
84+
glib::Object::builder()
85+
.property("application-id", application_id)
86+
.property("flags", flags)
87+
.build()
88+
}
8889

89-
fn setup_gactions(&self) {
90-
let quit_action = gio::ActionEntry::builder("quit")
91-
.activate(move |app: &Self, _, _| app.quit())
92-
.build();
93-
let about_action = gio::ActionEntry::builder("about")
94-
.activate(move |app: &Self, _, _| app.show_about())
95-
.build();
96-
self.add_action_entries([quit_action, about_action]);
97-
}
90+
fn setup_gactions(&self) {
91+
let quit_action = gio::ActionEntry::builder("quit")
92+
.activate(move |app: &Self, _, _| app.quit())
93+
.build();
94+
let about_action = gio::ActionEntry::builder("about")
95+
.activate(move |app: &Self, _, _| app.show_about())
96+
.build();
97+
self.add_action_entries([quit_action, about_action]);
98+
}
9899

99-
fn show_about(&self) {
100-
let window = self.active_window().unwrap();
101-
let about = adw::AboutDialog::builder()
102-
.application_icon("shutter")
103-
// TODO remove extra icons
104-
.application_icon("org.shutter-project.Shutter")
105-
.application_icon("shutter")
106-
.version(VERSION)
107-
.website("https://shutter-project.org")
108-
.issue_url("https://github.com/shutter-project/shutter/issues")
109-
.license_type(gtk::License::Gpl30)
110-
.artists(String::from_utf8(gio::resources_lookup_data("/org/shutter-project/Shutter/credits/art", gio::ResourceLookupFlags::empty()).expect("no artist data").to_vec()).expect("can't convert artists to utf8").lines().collect::<Vec<_>>())
111-
.developers(String::from_utf8(gio::resources_lookup_data("/org/shutter-project/Shutter/credits/dev", gio::ResourceLookupFlags::empty()).expect("no dev data").to_vec()).expect("can't convert devs to utf8").lines().collect::<Vec<_>>())
112-
.copyright(String::from_utf8(gio::resources_lookup_data("/org/shutter-project/Shutter/credits/copyright", gio::ResourceLookupFlags::empty()).expect("no copyright data").to_vec()).expect("can't convert copyright to utf8"))
113-
.build();
100+
fn show_about(&self) {
101+
let window = self.active_window().unwrap();
102+
let about = adw::AboutDialog::builder()
103+
.application_icon("shutter")
104+
// TODO remove extra icons
105+
.application_icon("org.shutter-project.Shutter")
106+
.application_icon("shutter")
107+
.version(VERSION)
108+
.website("https://shutter-project.org")
109+
.issue_url("https://github.com/shutter-project/shutter/issues")
110+
.license_type(gtk::License::Gpl30)
111+
.artists(
112+
String::from_utf8(
113+
gio::resources_lookup_data(
114+
"/org/shutter-project/Shutter/credits/art",
115+
gio::ResourceLookupFlags::empty(),
116+
)
117+
.expect("no artist data")
118+
.to_vec(),
119+
)
120+
.expect("can't convert artists to utf8")
121+
.lines()
122+
.collect::<Vec<_>>(),
123+
)
124+
.developers(
125+
String::from_utf8(
126+
gio::resources_lookup_data(
127+
"/org/shutter-project/Shutter/credits/dev",
128+
gio::ResourceLookupFlags::empty(),
129+
)
130+
.expect("no dev data")
131+
.to_vec(),
132+
)
133+
.expect("can't convert devs to utf8")
134+
.lines()
135+
.collect::<Vec<_>>(),
136+
)
137+
.copyright(
138+
String::from_utf8(
139+
gio::resources_lookup_data(
140+
"/org/shutter-project/Shutter/credits/copyright",
141+
gio::ResourceLookupFlags::empty(),
142+
)
143+
.expect("no copyright data")
144+
.to_vec(),
145+
)
146+
.expect("can't convert copyright to utf8"),
147+
)
148+
.build();
114149

115-
about.present(Some(&window));
116-
}
150+
about.present(Some(&window));
151+
}
117152
}

src/gtk/help-overlay.blp

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
using Gtk 4.0;
22

33
ShortcutsWindow help_overlay {
4-
modal: true;
4+
modal: true;
55

6-
ShortcutsSection {
7-
section-name: "shortcuts";
8-
max-height: 10;
6+
ShortcutsSection {
7+
section-name: "shortcuts";
8+
max-height: 10;
99

10-
ShortcutsGroup {
11-
title: C_("shortcut window", "General");
10+
ShortcutsGroup {
11+
title: C_("shortcut window", "General");
1212

13-
ShortcutsShortcut {
14-
title: C_("shortcut window", "Show Shortcuts");
15-
action-name: "win.show-help-overlay";
16-
}
13+
ShortcutsShortcut {
14+
title: C_("shortcut window", "Show Shortcuts");
15+
action-name: "win.show-help-overlay";
16+
}
1717

18-
ShortcutsShortcut {
19-
title: C_("shortcut window", "Quit");
20-
action-name: "app.quit";
21-
}
22-
}
23-
}
18+
ShortcutsShortcut {
19+
title: C_("shortcut window", "Quit");
20+
action-name: "app.quit";
21+
}
22+
}
23+
}
2424
}

src/gtk/menus.blp

+22-22
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
using Gtk 4.0;
22

33
menu menubar {
4-
submenu {
5-
label: _("Aaa");
4+
submenu {
5+
label: _("Aaa");
66

7-
item {
8-
label: _("_Preferences");
9-
action: "app.preferences";
10-
}
7+
item {
8+
label: _("_Preferences");
9+
action: "app.preferences";
10+
}
1111

12-
item {
13-
label: _("_About Shutter-Rust");
14-
action: "app.about";
15-
}
16-
}
12+
item {
13+
label: _("_About Shutter-Rust");
14+
action: "app.about";
15+
}
16+
}
1717

18-
submenu {
19-
label: _("_Help");
18+
submenu {
19+
label: _("_Help");
2020

21-
item {
22-
label: _("_Keyboard Shortcuts");
23-
action: "win.show-help-overlay";
24-
}
21+
item {
22+
label: _("_Keyboard Shortcuts");
23+
action: "win.show-help-overlay";
24+
}
2525

26-
item {
27-
label: _("_About");
28-
action: "app.about";
29-
}
30-
}
26+
item {
27+
label: _("_About");
28+
action: "app.about";
29+
}
30+
}
3131
}

0 commit comments

Comments
 (0)