Allow Wallpaper Dialog to set Wallpaper Mode
Description
This enhancement focuses on improving the WallpaperDialog
to support changing wallpaper modes dynamically using a GtkDropDown
. The changes provide more flexibility by allowing users to select from different modes (e.g., Centered, Scaled, Stretched, Zoom, etc.) via a dropdown in the dialog.
Proposed Changes
-
Add Wallpaper Mode Selection via
GtkDropDown
:- Introduce a new
GtkDropDown
to theWallpaperDialog
UI to allow users to change the wallpaper mode. - Populate the dropdown with different modes (
None
,Centered
,Scaled
,Stretched
, etc.) dynamically. - Handle the signal
notify::selected
to apply the selected wallpaper mode.
- Introduce a new
-
Update
WallpaperPreview
to Handle Wallpaper Mode:- Modify the
WallpaperPreview
widget to store and apply the selectedGDesktopBackgroundStyle
mode. - Add a new function
wallpaper_preview_set_mode()
that changes the wallpaper display style according to the selected mode.
- Modify the
Steps Implemented:
- Added a
GtkDropDown
for mode selection in thewallpaperdialog.ui
file. - Populated the
GtkDropDown
with wallpaper modes inwallpaperdialog.c
. - Created a signal handler
on_mode_changed
that applies the selected wallpaper mode. - Updated
WallpaperPreview
to store the current wallpaper mode and redraw the preview accordingly.
Benefits:
- This improvement allows users to select different wallpaper display modes directly from the
WallpaperDialog
. - The
WallpaperPreview
will now respond to mode changes, providing better feedback and control over wallpaper appearance.
Example:
When a user selects "Zoom" mode from the dropdown, the wallpaper preview will instantly reflect this change, and the selected mode will be stored.
Code Example:
static void
on_mode_changed(GtkDropDown *dropdown, GParamSpec *pspec, WallpaperDialog *self)
{
guint active = gtk_drop_down_get_selected(dropdown);
if (active != GTK_INVALID_LIST_POSITION && active < G_N_ELEMENTS(wallpaper_modes)) {
GDesktopBackgroundStyle mode = wallpaper_modes[active].mode;
wallpaper_preview_set_mode(self->desktop_preview, mode);
}
}
Related Files:
src/wallpaperdialog.c
src/wallpaperdialog.ui
src/wallpaperpreview.c
src/wallpaperpreview.h
Grabación_de_pantalla_desde_2024-09-05_03-36-45
Next Steps:
- Review the integration of
GtkDropDown
and ensure smooth interaction with theWallpaperPreview
. - Test the different modes to ensure correct application of wallpaper display styles.