# HG changeset patch
# Node ID d12bfe70878c
# Parent  79531847d72a
diff --git a/pidgin/gtkwhiteboard.c b/pidgin/gtkwhiteboard.c
--- a/pidgin/gtkwhiteboard.c
+++ b/pidgin/gtkwhiteboard.c
@@ -66,6 +66,7 @@ struct _PidginWhiteboard
 	PurpleWhiteboard *wb;
 
 	GtkWidget *drawing_area;
+	GtkBox *toolbar;
 	GtkWidget *color_button;
 
 	int width;
@@ -504,6 +505,25 @@ pidgin_whiteboard_button_save_press(G_GN
 #endif
 }
 
+#if GTK_CHECK_VERSION(4, 10, 0)
+static void
+notify_color_cb(GObject *obj, G_GNUC_UNUSED GParamSpec *pspec, gpointer data) {
+	PidginWhiteboard *gtkwb = data;
+	PurpleWhiteboard *wb = gtkwb->wb;
+	const GdkRGBA *color;
+	int old_size, old_color;
+	int new_color;
+
+	color = gtk_color_dialog_button_get_rgba(GTK_COLOR_DIALOG_BUTTON(obj));
+
+	new_color = (unsigned int)(color->red * 255) << 16;
+	new_color |= (unsigned int)(color->green * 255) << 8;
+	new_color |= (unsigned int)(color->blue * 255);
+
+	purple_whiteboard_get_brush(wb, &old_size, &old_color);
+	purple_whiteboard_send_brush(wb, old_size, new_color);
+}
+#else
 static void
 color_selected(GtkColorButton *button, PidginWhiteboard *gtkwb)
 {
@@ -521,6 +541,7 @@ color_selected(GtkColorButton *button, P
 	purple_whiteboard_get_brush(wb, &old_size, &old_color);
 	purple_whiteboard_send_brush(wb, old_size, new_color);
 }
+#endif
 
 static void
 pidgin_whiteboard_create(PurpleWhiteboard *wb)
@@ -564,8 +585,13 @@ pidgin_whiteboard_create(PurpleWhiteboar
 	                            gtkwb->width, gtkwb->height);
 
 	pidgin_whiteboard_rgb24_to_rgba(gtkwb->brush_color, &color);
+#if GTK_CHECK_VERSION(4, 10, 0)
+	gtk_color_dialog_button_set_rgba(GTK_COLOR_DIALOG_BUTTON(gtkwb->color_button),
+	                                 &color);
+#else
 	gtk_color_chooser_set_rgba(GTK_COLOR_CHOOSER(gtkwb->color_button),
 	                           &color);
+#endif
 
 	/* Make all this (window) visible */
 	gtk_widget_set_visible(GTK_WIDGET(gtkwb), TRUE);
@@ -599,6 +625,17 @@ pidgin_whiteboard_destroy(PurpleWhiteboa
 static void
 pidgin_whiteboard_init(PidginWhiteboard *self) {
 	gtk_widget_init_template(GTK_WIDGET(self));
+
+#if GTK_CHECK_VERSION(4, 10, 0)
+	self->color_button = gtk_color_dialog_button_new(gtk_color_dialog_new());
+	g_signal_connect(self->color_button, "notify::rgba",
+	                 G_CALLBACK(notify_color_cb), self);
+#else
+	self->color_button = gtk_color_button_new();
+	g_signal_connect(self->color_button, "color-set",
+	                 G_CALLBACK(color_selected), self);
+#endif
+	gtk_box_append(self->toolbar, GTK_WIDGET(self->color_button));
 }
 
 static void
@@ -626,7 +663,7 @@ pidgin_whiteboard_class_init(PidginWhite
 	gtk_widget_class_bind_template_child(widget_class, PidginWhiteboard,
 	                                     drawing_area);
 	gtk_widget_class_bind_template_child(widget_class, PidginWhiteboard,
-	                                     color_button);
+	                                     toolbar);
 
 	gtk_widget_class_bind_template_callback(
 	        widget_class, whiteboard_destroy_cb);
@@ -644,8 +681,6 @@ pidgin_whiteboard_class_init(PidginWhite
 	        widget_class, pidgin_whiteboard_button_clear_press);
 	gtk_widget_class_bind_template_callback(
 	        widget_class, pidgin_whiteboard_button_save_press);
-	gtk_widget_class_bind_template_callback(
-	        widget_class, color_selected);
 }
 
 /******************************************************************************
diff --git a/pidgin/resources/Whiteboard/whiteboard.ui b/pidgin/resources/Whiteboard/whiteboard.ui
--- a/pidgin/resources/Whiteboard/whiteboard.ui
+++ b/pidgin/resources/Whiteboard/whiteboard.ui
@@ -47,7 +47,7 @@ along with this program; if not, see <ht
           </object>
         </child>
         <child>
-          <object class="GtkBox">
+          <object class="GtkBox" id="toolbar">
             <property name="halign">center</property>
             <property name="orientation">vertical</property>
             <property name="spacing">6</property>
@@ -71,14 +71,6 @@ along with this program; if not, see <ht
                 <signal name="clicked" handler="pidgin_whiteboard_button_save_press" object="PidginWhiteboard" swapped="no"/>
               </object>
             </child>
-            <child>
-              <object class="GtkColorButton" id="color_button">
-                <property name="valign">center</property>
-                <property name="focusable">1</property>
-                <property name="receives-default">1</property>
-                <signal name="color-set" handler="color_selected" object="PidginWhiteboard" swapped="no"/>
-              </object>
-            </child>
           </object>
         </child>
       </object>
