Skip to content

Commit ad88762

Browse files
committed
Ensure the swatches is part of the color picker
1 parent af60407 commit ad88762

1 file changed

Lines changed: 33 additions & 10 deletions

File tree

src/components/palette-editor/ColorPaletteSection.js

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,24 +119,47 @@ export const ColorPaletteSection = GObject.registerClass(
119119
margin_end: 12,
120120
});
121121

122+
// Swatch selector label
123+
const selectorLabel = new Gtk.Label({
124+
label: 'Select a color slot to replace:',
125+
css_classes: ['caption', 'dim-label'],
126+
xalign: 0,
127+
margin_bottom: 6,
128+
});
129+
content.append(selectorLabel);
130+
131+
// Create mini swatch grid (reuse ColorSwatchGrid in mini mode)
132+
const miniSwatchGrid = new ColorSwatchGrid(null, {
133+
miniMode: true,
134+
showLockButtons: false,
135+
selectedIndex: 0,
136+
});
137+
miniSwatchGrid.setPalette([...this._palette]);
138+
content.append(miniSwatchGrid.widget);
139+
122140
// Create color picker
123141
const colorPicker = new WallpaperColorPicker(this._currentWallpaper);
124142
content.append(colorPicker);
125143

126144
// Handle color selection
127145
colorPicker.connect('color-picked', (_, color) => {
128-
// Find first unlocked color slot
129-
const lockedColors = this._swatchGrid.getLockedColors();
130-
const firstUnlocked = lockedColors.findIndex(locked => !locked);
131-
132-
if (firstUnlocked !== -1) {
133-
this._palette[firstUnlocked] = color;
134-
this._swatchGrid.updateSwatchColor(firstUnlocked, color);
135-
this.emit('color-changed', firstUnlocked, color);
136-
}
146+
const index = miniSwatchGrid.getSelectedIndex();
147+
148+
// Update palette
149+
this._palette[index] = color;
150+
this._swatchGrid.updateSwatchColor(index, color);
151+
miniSwatchGrid.updateSwatchColor(index, color);
152+
this.emit('color-changed', index, color);
153+
});
137154

138-
dialog.close();
155+
// Done button
156+
const doneButton = new Gtk.Button({
157+
label: 'Done',
158+
css_classes: ['suggested-action'],
159+
halign: Gtk.Align.END,
139160
});
161+
doneButton.connect('clicked', () => dialog.close());
162+
content.append(doneButton);
140163

141164
dialog.set_child(content);
142165
dialog.present(this.get_root());

0 commit comments

Comments
 (0)