File tree Expand file tree Collapse file tree 2 files changed +25
-8
lines changed Expand file tree Collapse file tree 2 files changed +25
-8
lines changed Original file line number Diff line number Diff line change 1+ sudo rm -r build
2+ meson build
3+ cd build
4+ mesonconf -Dprefix=/usr
5+ ninja
6+ ./com.github.ronnydo.colorpicker
7+ cd ..
Original file line number Diff line number Diff line change @@ -87,19 +87,29 @@ namespace ColorPicker.Widgets {
8787 }
8888
8989 public void add_color (Gdk .RGBA color ) {
90- if (color_list. size >= max_colors) {
91- remove_oldest_color ();
92- }
90+ int c_index = get_index_of (color);
91+
92+ if (c_index < 0 ) {
93+ if (color_list. size >= max_colors) {
94+ color_list. remove_at (0 );
95+ }
96+ } else {
97+ color_list. remove_at (c_index);
98+ }
99+
93100 color_list. add (color);
94101 store_colors ();
95-
96102 selected_color = get_color_list (). size - 1 ;
97103 }
98104
99- public void remove_oldest_color () {
100- color_list. remove_at (0 );
101- store_colors ();
102- }
105+ public int get_index_of (Gdk .RGBA color ) {
106+ for (int i = 0 ; i < color_list. size; i++ ) {
107+ if (color_list[i] == color) {
108+ return i;
109+ }
110+ }
111+ return - 1 ;
112+ }
103113
104114 public Gee .ArrayList<Gdk . RGBA ?> get_color_list () {
105115 return color_list;
You can’t perform that action at this time.
0 commit comments