Skip to content

Commit 53dca47

Browse files
authored
Update main.rs
1 parent f596c10 commit 53dca47

File tree

1 file changed

+106
-92
lines changed

1 file changed

+106
-92
lines changed

source-code/src/main.rs

Lines changed: 106 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,110 @@
1-
import sys
2-
import gi
3-
gi.require_version('Gtk', '4.0')
4-
gi.require_version('Adw', '1')
5-
from gi.repository import Gtk, Adw, Gio
6-
from ui import build_ui
7-
from actions import Actions
1+
// src/main.rs
2+
use adw::prelude::*;
3+
use adw::{Application, ApplicationWindow, HeaderBar, StyleManager};
4+
use gio::prelude::*;
5+
use glib::clone;
6+
use gtk::prelude::*;
7+
use gtk::{Box as GtkBox, Button, CssProvider, FlowBox, Image, Label, Orientation, PolicyType, ScrolledWindow, Separator, StyleContext};
8+
use std::cell::RefCell;
9+
use std::env;
10+
use std::path::Path;
11+
use std::rc::Rc;
12+
use gdk_pixbuf::Pixbuf;
813

9-
class HackerOSWelcome(Adw.ApplicationWindow):
10-
def __init__(self, *args, **kwargs):
11-
super().__init__(*args, **kwargs)
12-
self.actions = Actions(self)
13-
self.set_title("HackerOS Welcome")
14-
self.set_default_size(1000, 750)
15-
# Set dark theme using Adw.StyleManager
16-
style_manager = Adw.StyleManager.get_default()
17-
style_manager.set_color_scheme(Adw.ColorScheme.FORCE_DARK)
18-
# Stylizacja - rozbudowany CSS dla ładniejszego wyglądu
19-
self.style_provider = Gtk.CssProvider()
20-
css = """
21-
window {
22-
background-color: #121212;
23-
color: white;
24-
border-radius: 12px;
25-
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
26-
}
27-
label {
28-
color: white;
29-
text-shadow: 1px 1px 2px black;
30-
}
31-
button {
32-
background-color: #1E1E1E;
33-
color: white;
34-
border: 2px solid #555;
35-
border-radius: 8px;
36-
padding: 12px 20px;
37-
font-size: 16px;
38-
font-weight: bold;
39-
transition: all 0.3s ease;
40-
}
41-
button:hover {
42-
background-color: #333;
43-
border-color: #777;
44-
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
45-
}
46-
button:active {
47-
background-color: #444;
48-
box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
49-
}
50-
.title {
51-
font-size: 32px;
52-
font-weight: bold;
53-
color: #FFFFFF;
54-
}
55-
.subtitle {
56-
font-size: 20px;
57-
color: #CCCCCC;
58-
}
59-
separator {
60-
background-color: #555;
61-
margin: 10px 0;
62-
}
63-
scrolledwindow {
64-
background-color: #181818;
65-
border-radius: 8px;
66-
padding: 10px;
67-
}
68-
.footer {
69-
font-size: 14px;
70-
color: #888888;
71-
padding: 10px;
72-
background-color: #0A0A0A;
73-
border-top: 1px solid #333;
74-
}
75-
"""
76-
self.style_provider.load_from_data(css.encode())
77-
Gtk.StyleContext.add_provider_for_display(
78-
self.get_display(),
79-
self.style_provider,
80-
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
81-
)
82-
build_ui(self)
14+
mod actions;
15+
mod ui;
8316

84-
class Application(Adw.Application):
85-
def __init__(self):
86-
super().__init__(application_id="org.hackeros.welcome",
87-
flags=Gio.ApplicationFlags.FLAGS_NONE)
88-
self.connect("activate", self.on_activate)
17+
use actions::Actions;
18+
use ui::build_ui;
8919

90-
def on_activate(self, app):
91-
win = HackerOSWelcome(application=app)
92-
win.present()
20+
fn main() {
21+
let application = Application::builder()
22+
.application_id("org.hackeros.welcome")
23+
.build();
9324

94-
if __name__ == '__main__':
95-
app = Application()
96-
app.run(sys.argv)
25+
application.connect_startup(|_| {
26+
StyleManager::default().set_color_scheme(adw::ColorScheme::ForceDark);
27+
});
28+
29+
application.connect_activate(|app| {
30+
let window = ApplicationWindow::builder()
31+
.application(app)
32+
.title("HackerOS Welcome")
33+
.default_width(1000)
34+
.default_height(750)
35+
.build();
36+
37+
// Load CSS
38+
let provider = CssProvider::new();
39+
provider.load_from_data("
40+
window {
41+
background-color: #121212;
42+
color: white;
43+
border-radius: 12px;
44+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
45+
}
46+
label {
47+
color: white;
48+
text-shadow: 1px 1px 2px black;
49+
}
50+
button {
51+
background-color: #1E1E1E;
52+
color: white;
53+
border: 2px solid #555;
54+
border-radius: 8px;
55+
padding: 12px 20px;
56+
font-size: 16px;
57+
font-weight: bold;
58+
transition: all 0.3s ease;
59+
}
60+
button:hover {
61+
background-color: #333;
62+
border-color: #777;
63+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
64+
}
65+
button:active {
66+
background-color: #444;
67+
box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
68+
}
69+
.title {
70+
font-size: 32px;
71+
font-weight: bold;
72+
color: #FFFFFF;
73+
}
74+
.subtitle {
75+
font-size: 20px;
76+
color: #CCCCCC;
77+
}
78+
separator {
79+
background-color: #555;
80+
margin: 10px 0;
81+
}
82+
scrolledwindow {
83+
background-color: #181818;
84+
border-radius: 8px;
85+
padding: 10px;
86+
}
87+
.footer {
88+
font-size: 14px;
89+
color: #888888;
90+
padding: 10px;
91+
background-color: #0A0A0A;
92+
border-top: 1px solid #333;
93+
}
94+
");
95+
96+
StyleContext::add_provider_for_display(
97+
&gtk::gdk::Display::default().expect("Error initializing GTK CSS provider."),
98+
&provider,
99+
gtk::STYLE_PROVIDER_PRIORITY_APPLICATION,
100+
);
101+
102+
let actions = Rc::new(RefCell::new(Actions::new()));
103+
104+
build_ui(&window, actions.clone());
105+
106+
window.present();
107+
});
108+
109+
application.run_with_args(&env::args().collect::<Vec<_>>());
110+
}

0 commit comments

Comments
 (0)