mirror of
https://github.com/GradienceTeam/Gradience.git
synced 2024-07-07 11:37:50 +00:00
fix: begin adding a share window feature
This commit is contained in:
parent
65efa54c67
commit
3718d20db0
|
@ -20,6 +20,7 @@
|
|||
<file preprocess="xml-stripblanks">ui/preferences.ui</file>
|
||||
<file preprocess="xml-stripblanks">ui/repo_row.ui</file>
|
||||
<file preprocess="xml-stripblanks">ui/no_plugin_pref.ui</file>
|
||||
<file preprocess="xml-stripblanks">ui/share_window.ui</file>
|
||||
<file>style.css</file>
|
||||
<file>images/welcome.svg</file>
|
||||
<file>images/welcome-dark.svg</file>
|
||||
|
|
|
@ -15,6 +15,7 @@ blueprints = custom_target('blueprints',
|
|||
'explore_preset_row.blp',
|
||||
'repo_row.blp',
|
||||
'no_plugin_pref.blp',
|
||||
'share_window.blp',
|
||||
),
|
||||
output: '.',
|
||||
command: [find_program('blueprint-compiler'), 'batch-compile', '@OUTPUT@', '@CURRENT_SOURCE_DIR@', '@INPUT@']
|
||||
|
|
|
@ -19,6 +19,14 @@ Popover pop_actions {
|
|||
label: _("Remove preset");
|
||||
tooltip-text: _("Remove preset");
|
||||
clicked => on_remove_button_clicked();
|
||||
styles ["flat"]
|
||||
}
|
||||
|
||||
Button btn_share {
|
||||
valign: center;
|
||||
label: _("Share preset");
|
||||
tooltip-text: _("Share preset");
|
||||
styles ["flat"]
|
||||
}
|
||||
|
||||
Separator {
|
||||
|
|
|
@ -0,0 +1,205 @@
|
|||
using Gtk 4.0;
|
||||
using Adw 1;
|
||||
|
||||
template GradienceShareWindow: Adw.Window {
|
||||
title: _("Share your preset");
|
||||
resizable: true;
|
||||
deletable: true;
|
||||
modal: true;
|
||||
default-width: 500;
|
||||
default-height: 500;
|
||||
|
||||
Adw.ToastOverlay toast_overlay {
|
||||
Adw.Leaflet leaflet {
|
||||
can-navigate-back: false;
|
||||
can-unfold: false;
|
||||
|
||||
Gtk.Box main_view {
|
||||
orientation: vertical;
|
||||
|
||||
Adw.HeaderBar titlebar {
|
||||
styles ["flat"]
|
||||
centering-policy: strict;
|
||||
|
||||
[title]
|
||||
Adw.CarouselIndicatorDots {
|
||||
styles ["flat"]
|
||||
carousel: carousel;
|
||||
orientation: horizontal;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Gtk.Overlay {
|
||||
[overlay]
|
||||
Gtk.Button btn_back {
|
||||
styles ["circular"]
|
||||
margin-start: 10;
|
||||
icon-name: "go-previous-symbolic";
|
||||
halign: start;
|
||||
valign: center;
|
||||
visible: false;
|
||||
tooltip-text: _("Previous");
|
||||
}
|
||||
|
||||
child: Adw.Carousel carousel {
|
||||
vexpand: true;
|
||||
hexpand: true;
|
||||
allow-scroll-wheel: true;
|
||||
allow-mouse-drag: true;
|
||||
allow-long-swipes: false;
|
||||
margin-start: 10;
|
||||
margin-end: 10;
|
||||
|
||||
Gtk.Box {
|
||||
orientation: vertical;
|
||||
vexpand: true;
|
||||
hexpand: true;
|
||||
|
||||
Gtk.Image img_welcome {
|
||||
resource: "/com/github/GradienceTeam/Gradience/images/welcome.svg";
|
||||
pixel-size: 256;
|
||||
}
|
||||
|
||||
Adw.StatusPage page_welcome {
|
||||
title: _("Share your preset");
|
||||
description: _("Share your preset with the world!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Adw.StatusPage page_release {
|
||||
icon-name: "git-symbolic";
|
||||
title: _("How it's work?");
|
||||
description: _("Gradience use GitHub to share your preset. You need to create a GitHub account and fork <a href='https://github.com/GradienceTeam/Community'>GradienceTeam/Community</a>. Then, you can upload your preset, make a pull request and share it with the world!");
|
||||
}
|
||||
|
||||
Adw.StatusPage page_agreement {
|
||||
vexpand: true;
|
||||
hexpand: true;
|
||||
icon-name: "dialog-warning-symbolic";
|
||||
title: _("Warning");
|
||||
description: _("Changing the colour scheme can negatively affect contrast and readability. Proceed with caution. Please do not report theming-related issues to app developers.");
|
||||
|
||||
Gtk.Button btn_agree {
|
||||
styles ["suggested-action", "pill"]
|
||||
label: _("I understand the consequences");
|
||||
use-underline: true;
|
||||
halign: center;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Adw.StatusPage page_gradience {
|
||||
vexpand: true;
|
||||
hexpand: true;
|
||||
icon-name: "larger-brush-symbolic";
|
||||
title: _("Customize Adwaita Theme");
|
||||
description: _("Change colours of windows, buttons, lists and more, with advanced features like adding custom CSS");
|
||||
}
|
||||
|
||||
Adw.StatusPage page_configure {
|
||||
vexpand: true;
|
||||
hexpand: true;
|
||||
title: _("Configure Gradience");
|
||||
description: _("Install adw-gtk3 theme for legacy applications and configure system for theming.");
|
||||
|
||||
Adw.PreferencesPage {
|
||||
Adw.PreferencesGroup {
|
||||
Adw.ActionRow configure_adw_gtk3 {
|
||||
title: _("Legacy apps theming");
|
||||
activatable-widget: switch_adw_gtk3;
|
||||
[suffix]
|
||||
Switch switch_adw_gtk3 {
|
||||
valign: center;
|
||||
tooltip-text: _("Install adw-gtk3 theme for legacy apps theming");
|
||||
}
|
||||
}
|
||||
|
||||
Adw.ActionRow configure_system {
|
||||
title: _("System configuration");
|
||||
activatable-widget: switch_system;
|
||||
|
||||
[suffix]
|
||||
Switch switch_system {
|
||||
valign: center;
|
||||
tooltip-text: _("Configure system for theming, enables Flatpak theme override");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Adw.StatusPage page_download {
|
||||
vexpand: true;
|
||||
hexpand: true;
|
||||
title: _("Installing Themes");
|
||||
description: _("Please wait until theme will be installed.");
|
||||
|
||||
Gtk.Box {
|
||||
orientation: vertical;
|
||||
Gtk.Button btn_install {
|
||||
styles ["suggested-action", "pill"]
|
||||
label: _("Continue");
|
||||
use-underline: true;
|
||||
halign: center;
|
||||
|
||||
}
|
||||
|
||||
Gtk.ProgressBar progressbar {
|
||||
halign: center;
|
||||
visible: false;
|
||||
margin-top: 24;
|
||||
margin-bottom: 24;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Adw.StatusPage page_finish {
|
||||
vexpand: true;
|
||||
hexpand: true;
|
||||
icon-name: "selection-mode-symbolic";
|
||||
title: _("Done");
|
||||
description: _("Now you can make your own presets or download some online.");
|
||||
|
||||
Gtk.Box {
|
||||
orientation: vertical;
|
||||
Gtk.Button label_skip {
|
||||
label: _("Please finish the setup first");
|
||||
margin-bottom: 24;
|
||||
visible: true;
|
||||
|
||||
}
|
||||
|
||||
Gtk.Button btn_close {
|
||||
styles ["suggested-action", "pill"]
|
||||
label: _("Start using Gradience");
|
||||
use-underline: true;
|
||||
halign: center;
|
||||
visible: true;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
[overlay]
|
||||
Gtk.Button btn_next {
|
||||
styles ["circular", "suggested-action"]
|
||||
margin-end: 10;
|
||||
icon-name: "go-next-symbolic";
|
||||
halign: end;
|
||||
valign: center;
|
||||
visible: false;
|
||||
tooltip-text: _("Next");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -56,6 +56,7 @@ gradience_sources = [
|
|||
'welcome.py',
|
||||
'repo_row.py',
|
||||
'no_plugin_pref.py',
|
||||
'share_window.py',
|
||||
]
|
||||
|
||||
PY_INSTALLDIR.install_sources(gradience_sources, subdir: 'gradience')
|
||||
|
|
|
@ -26,7 +26,7 @@ from .constants import rootdir
|
|||
from .modules.utils import to_slug_case, buglog
|
||||
from .modules.preset import Preset
|
||||
|
||||
|
||||
from .share_window import GradienceShareWindow
|
||||
@Gtk.Template(resource_path=f"{rootdir}/ui/preset_row.ui")
|
||||
class GradiencePresetRow(Adw.ExpanderRow):
|
||||
__gtype_name__ = "GradiencePresetRow"
|
||||
|
@ -37,6 +37,7 @@ class GradiencePresetRow(Adw.ExpanderRow):
|
|||
apply_button = Gtk.Template.Child("apply_button")
|
||||
remove_button = Gtk.Template.Child("remove_button")
|
||||
btn_report = Gtk.Template.Child("btn_report")
|
||||
btn_share = Gtk.Template.Child("btn_share")
|
||||
star_button = Gtk.Template.Child("star_button")
|
||||
|
||||
def __init__(self, name, win, repo_name, file_name, author="", **kwargs):
|
||||
|
@ -59,6 +60,7 @@ class GradiencePresetRow(Adw.ExpanderRow):
|
|||
self.preset = Preset(name, repo_name)
|
||||
|
||||
self.btn_report.connect("clicked", self.on_report_btn_clicked)
|
||||
self.btn_share.connect("clicked", self.on_share_btn_clicked)
|
||||
self.star_button.connect("clicked", self.on_star_button_clicked)
|
||||
|
||||
if name in self.win.app.favourite:
|
||||
|
@ -66,6 +68,12 @@ class GradiencePresetRow(Adw.ExpanderRow):
|
|||
else:
|
||||
self.star_button.set_icon_name("non-starred-symbolic")
|
||||
|
||||
def on_share_btn_clicked(self, *_args):
|
||||
buglog("share")
|
||||
win = GradienceShareWindow(self.win)
|
||||
win.present()
|
||||
|
||||
|
||||
def on_star_button_clicked(self, *_args):
|
||||
buglog("star")
|
||||
if self.name in self.win.app.favourite:
|
||||
|
|
159
gradience/share_window.py
Normal file
159
gradience/share_window.py
Normal file
|
@ -0,0 +1,159 @@
|
|||
import sys
|
||||
import time
|
||||
|
||||
from gi.repository import Gtk, Adw, Gio
|
||||
|
||||
from .modules.run_async import RunAsync
|
||||
from .modules.utils import buglog
|
||||
from .modules.flatpak_overrides import create_gtk_user_override
|
||||
from .constants import rootdir, app_id, rel_ver
|
||||
|
||||
|
||||
@Gtk.Template(resource_path=f"{rootdir}/ui/share_window.ui")
|
||||
class GradienceShareWindow(Adw.Window):
|
||||
__gtype_name__ = "GradienceShareWindow"
|
||||
|
||||
settings = Gtk.Settings.get_default()
|
||||
|
||||
btn_close = Gtk.Template.Child()
|
||||
btn_back = Gtk.Template.Child()
|
||||
btn_next = Gtk.Template.Child()
|
||||
btn_install = Gtk.Template.Child()
|
||||
btn_agree = Gtk.Template.Child()
|
||||
|
||||
carousel = Gtk.Template.Child()
|
||||
|
||||
switch_system = Gtk.Template.Child()
|
||||
switch_adw_gtk3 = Gtk.Template.Child()
|
||||
|
||||
progressbar = Gtk.Template.Child()
|
||||
img_welcome = Gtk.Template.Child()
|
||||
label_skip = Gtk.Template.Child()
|
||||
|
||||
images = [
|
||||
f"{rootdir}/images/welcome.svg",
|
||||
f"{rootdir}/images/welcome-dark.svg",
|
||||
]
|
||||
|
||||
carousel_pages = [
|
||||
"welcome", # 0
|
||||
"gradience", # 1
|
||||
"configure", # 2
|
||||
"download", # 3
|
||||
"finish", # 4
|
||||
]
|
||||
|
||||
page_welcome = Gtk.Template.Child()
|
||||
page_release = Gtk.Template.Child()
|
||||
|
||||
def __init__(self, window, **kwargs) -> None:
|
||||
super().__init__(**kwargs)
|
||||
|
||||
self.set_transient_for(window)
|
||||
|
||||
# common variables and references
|
||||
self.window = window
|
||||
|
||||
self.gio_settings = Gio.Settings(app_id)
|
||||
|
||||
# connect signals
|
||||
self.carousel.connect("page-changed", self.page_changed)
|
||||
self.btn_close.connect("clicked", self.close_window)
|
||||
self.btn_back.connect("clicked", self.previous_page)
|
||||
self.btn_next.connect("clicked", self.next_page)
|
||||
self.btn_install.connect("clicked", self.install_runner)
|
||||
|
||||
self.settings.connect(
|
||||
"notify::gtk-application-prefer-dark-theme", self.theme_changed
|
||||
)
|
||||
self.connect("close-request", self.quit)
|
||||
|
||||
self.btn_close.set_sensitive(False)
|
||||
|
||||
if self.settings.get_property("gtk-application-prefer-dark-theme"):
|
||||
self.img_welcome.set_from_resource(self.images[1])
|
||||
|
||||
self.page_changed()
|
||||
|
||||
def theme_changed(self, settings, key):
|
||||
self.img_welcome.set_from_resource(
|
||||
self.images[settings.get_property(
|
||||
"gtk-application-prefer-dark-theme")]
|
||||
)
|
||||
|
||||
def get_page(self, index):
|
||||
return self.carousel_pages[index]
|
||||
|
||||
def page_changed(self, widget=False, index=0, *_args):
|
||||
"""
|
||||
This function is called on first load and when the user require
|
||||
to change the page. It sets the widgets status according to
|
||||
the step of the onboard progress.
|
||||
"""
|
||||
page = self.get_page(index)
|
||||
|
||||
if page == "finish":
|
||||
self.btn_back.set_visible(False)
|
||||
self.btn_next.set_visible(False)
|
||||
self.carousel.set_interactive(False)
|
||||
elif page == "download":
|
||||
self.btn_back.set_visible(True)
|
||||
self.btn_next.set_visible(False)
|
||||
self.btn_install.set_visible(True)
|
||||
self.carousel.set_interactive(False)
|
||||
elif page == "welcome":
|
||||
self.btn_back.set_visible(False)
|
||||
self.btn_next.set_visible(True)
|
||||
self.carousel.set_interactive(True)
|
||||
else:
|
||||
self.btn_back.set_visible(True)
|
||||
self.btn_next.set_visible(True)
|
||||
self.btn_install.set_visible(False)
|
||||
self.carousel.set_interactive(True)
|
||||
|
||||
|
||||
def quit(self, *args):
|
||||
self.destroy()
|
||||
|
||||
def install_runner(self, widget):
|
||||
def set_completed(result, error=False):
|
||||
self.label_skip.set_visible(False)
|
||||
self.btn_close.set_sensitive(True)
|
||||
self.window.settings.set_boolean("first-run", False)
|
||||
self.next_page()
|
||||
|
||||
self.installing = True
|
||||
self.set_deletable(False)
|
||||
|
||||
def install():
|
||||
print("Installing Gradience...")
|
||||
|
||||
RunAsync(self.pulse)
|
||||
RunAsync(
|
||||
install,
|
||||
callback=set_completed,
|
||||
)
|
||||
|
||||
def previous_page(self, widget=False, index=None):
|
||||
if index is None:
|
||||
index = int(self.carousel.get_position())
|
||||
|
||||
previous_page = self.carousel.get_nth_page(index - 1)
|
||||
self.carousel.scroll_to(previous_page, True)
|
||||
|
||||
def next_page(self, widget=False, index=None):
|
||||
if index is None:
|
||||
index = int(self.carousel.get_position())
|
||||
|
||||
next_page = self.carousel.get_nth_page(index + 1)
|
||||
self.carousel.scroll_to(next_page, True)
|
||||
|
||||
def pulse(self):
|
||||
# This function updates the progress bar every 1s.
|
||||
while True:
|
||||
time.sleep(0.5)
|
||||
self.progressbar.pulse()
|
||||
|
||||
def close_window(self, widget):
|
||||
self.destroy()
|
||||
self.window.present()
|
Loading…
Reference in a new issue