@@ -62,10 +62,12 @@ public class MainWindow : Gtk.Window {
6262 fg_entry = new Gtk .Entry ();
6363 fg_entry. text = settings. get_string (" fg-color" );
6464 fg_entry. placeholder_text = _(" #333" );
65+ fg_entry. set_icon_from_icon_name (Gtk . EntryIconPosition . SECONDARY , " media-eq-symbolic" );
6566
6667 bg_entry = new Gtk .Entry ();
6768 bg_entry. text = settings. get_string (" bg-color" );
6869 bg_entry. placeholder_text = _(" rgb (110, 200, 230)" );
70+ bg_entry. set_icon_from_icon_name (Gtk . EntryIconPosition . SECONDARY , " media-eq-symbolic" );
6971
7072 var input_grid = new Gtk .Grid ();
7173 input_grid. orientation = Gtk . Orientation . VERTICAL ;
@@ -129,25 +131,45 @@ public class MainWindow : Gtk.Window {
129131 set_titlebar (header_grid);
130132 show_all ();
131133
132- button_press_event. connect ((e) = > {
133- if (e. button == Gdk . BUTTON_PRIMARY ) {
134- begin_move_drag ((int ) e. button, (int ) e. x_root, (int ) e. y_root, e. time);
135- return true ;
134+ fg_entry. icon_press. connect ((pos, event) = > {
135+ if (pos == Gtk . EntryIconPosition . SECONDARY ) {
136+ on_entry_icon_press (fg_entry. text);
136137 }
137- return false ;
138138 });
139139
140140 fg_entry. changed. connect (() = > {
141141 on_entry_changed ();
142142 });
143143
144+ bg_entry. icon_press. connect ((pos, event) = > {
145+ if (pos == Gtk . EntryIconPosition . SECONDARY ) {
146+ on_entry_icon_press (bg_entry. text);
147+ }
148+ });
149+
144150 bg_entry. changed. connect (() = > {
145151 on_entry_changed ();
146152 });
147153
148154 style_results_pane (fg_entry. text, bg_entry. text);
149155 }
150156
157+ private void on_entry_icon_press (string color_string ) {
158+ gdk_color. parse (color_string);
159+
160+ var dialog = new Gtk .ColorSelectionDialog (" " );
161+ dialog. deletable = false ;
162+ dialog. transient_for = this ;
163+
164+ unowned Gtk . ColorSelection widget = dialog. get_color_selection ();
165+ widget. current_rgba = gdk_color;
166+
167+ if (dialog. run () == Gtk . ResponseType . OK ) {
168+ fg_entry. text = widget. current_rgba. to_string ();
169+ }
170+ dialog. close ();
171+ }
172+
151173 private void on_entry_changed () {
152174 if (fg_entry. text. length > 2 && bg_entry. text. length > 2 ) {
153175 style_results_pane (fg_entry. text, bg_entry. text);
0 commit comments