Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions data/be.alexandervanhee.gradia.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@
<summary>Whether to ask before running the export command.</summary>
</key>

<key name="image-options-expanded" type="b">
<default>true</default>
<summary>Whether the Image Options panel is expanded.</summary>
</key>
<key name="file-info-expanded" type="b">
<default>true</default>
<summary>Whether the Current File panel is expanded.</summary>
</key>

<key name="source-snippet-show-frame" type="b">
<default>true</default>
<summary>Whether to have a window frame for the source snippet.</summary>
Expand Down
9 changes: 6 additions & 3 deletions data/ui/image_sidebar.blp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ template $GradiaImageSidebar : Adw.Bin {
Adw.PreferencesGroup background_selector_group {}

Adw.PreferencesGroup image_options_group {
title: _("Image Options");
Adw.ExpanderRow image_options_expander {
title: _("Image Options");

Adw.SpinRow padding_row {
title: _("Padding");
Expand Down Expand Up @@ -129,11 +130,12 @@ template $GradiaImageSidebar : Adw.Bin {
}
}
}

}
}

Adw.PreferencesGroup file_info_group {
title: _("Current File");
Adw.ExpanderRow file_info_expander {
title: _("Current File");

Adw.ActionRow filename_row {
title: _("Name");
Expand Down Expand Up @@ -165,6 +167,7 @@ template $GradiaImageSidebar : Adw.Bin {
subtitle: _("N/A");
styles ["property"]
}
}
}
};
};
Expand Down
11 changes: 11 additions & 0 deletions gradia/backend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,17 @@ def bind_scale(self, scale: Gtk.Scale, key: str) -> None:
else:
print(f"Warning: GSettings key '{key}' not found in schema.")

def bind_property(self, widget: object, prop: str, key: str) -> None:
if key in self._settings.list_keys():
self._settings.bind(
key,
widget,
prop,
Gio.SettingsBindFlags.DEFAULT
)
else:
print(f"Warning: GSettings key '{key}' not found in schema.")

def bind_spin_row(self, spin_row: object, key: str) -> None:
if key in self._settings.list_keys():
self._settings.bind(
Expand Down
5 changes: 4 additions & 1 deletion gradia/ui/image_sidebar.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class ImageSidebar(Adw.Bin):
drawing_tools_group: DrawingToolsGroup = Gtk.Template.Child()
background_selector_group: Adw.PreferencesGroup = Gtk.Template.Child()
image_options_group = Gtk.Template.Child()
image_options_expander: Adw.ExpanderRow = Gtk.Template.Child()
padding_row: Adw.SpinRow = Gtk.Template.Child()
padding_adjustment: Gtk.Adjustment = Gtk.Template.Child()
corner_radius_row: Adw.SpinRow = Gtk.Template.Child()
Expand All @@ -54,6 +55,7 @@ class ImageSidebar(Adw.Bin):
filename_row: Adw.ActionRow = Gtk.Template.Child()
location_row: Adw.ActionRow = Gtk.Template.Child()
processed_size_row: Adw.ActionRow = Gtk.Template.Child()
file_info_expander: Adw.ExpanderRow = Gtk.Template.Child()
share_button: Gtk.Button = Gtk.Template.Child()
rotate_left_button: Gtk.Button = Gtk.Template.Child()
rotate_right_button: Gtk.Button = Gtk.Template.Child()
Expand All @@ -72,7 +74,6 @@ def __init__(
self._current_rotation = 0
self._current_background = None

self.image_options_group_content = self.image_options_group.get_first_child().get_first_child().get_next_sibling()
self.background_selector: BackgroundSelector = BackgroundSelector(
callback=self._on_background_changed
)
Expand All @@ -90,6 +91,8 @@ def _setup_widgets(self) -> None:
self.auto_balance_toggle.set_active(self.settings.image_auto_balance)
self.aspect_ratio_selector.set_ratio(self.settings.image_aspect_ratio)
self._current_rotation = self.settings.image_rotation
self.settings.bind_property(self.image_options_expander, "expanded", "image-options-expanded")
self.settings.bind_property(self.file_info_expander, "expanded", "file-info-expanded")

def _on_background_changed(self, updated_background: Background) -> None:
self._current_background = updated_background
Expand Down