Commit 6280e493 authored by Michael Natterer's avatar Michael Natterer 😴

app: add gimp_handle_bar_connect_events()

to replace 3 completely ugly signal connections, repeated in 4 places.
parent 640189d0
......@@ -414,29 +414,10 @@ gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool)
gtk_box_pack_start (GTK_BOX (vbox3), handle_bar, FALSE, FALSE, 0);
gtk_widget_show (handle_bar);
g_signal_connect_swapped (tool->input_bar, "button-press-event",
G_CALLBACK (GTK_WIDGET_GET_CLASS (handle_bar)->button_press_event),
handle_bar);
g_signal_connect_swapped (tool->input_bar, "button-release-event",
G_CALLBACK (GTK_WIDGET_GET_CLASS (handle_bar)->button_release_event),
handle_bar);
g_signal_connect_swapped (tool->input_bar, "motion-notify-event",
G_CALLBACK (GTK_WIDGET_GET_CLASS (handle_bar)->motion_notify_event),
handle_bar);
g_signal_connect_swapped (bar, "button-press-event",
G_CALLBACK (GTK_WIDGET_GET_CLASS (handle_bar)->button_press_event),
handle_bar);
g_signal_connect_swapped (bar, "button-release-event",
G_CALLBACK (GTK_WIDGET_GET_CLASS (handle_bar)->button_release_event),
handle_bar);
g_signal_connect_swapped (bar, "motion-notify-event",
G_CALLBACK (GTK_WIDGET_GET_CLASS (handle_bar)->motion_notify_event),
handle_bar);
gimp_handle_bar_connect_events (GIMP_HANDLE_BAR (handle_bar),
tool->input_bar);
gimp_handle_bar_connect_events (GIMP_HANDLE_BAR (handle_bar),
bar);
/* Horizontal box for input levels spinbuttons */
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
......@@ -529,17 +510,8 @@ gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool)
gtk_box_pack_start (GTK_BOX (vbox2), handle_bar, FALSE, FALSE, 0);
gtk_widget_show (handle_bar);
g_signal_connect_swapped (tool->output_bar, "button-press-event",
G_CALLBACK (GTK_WIDGET_GET_CLASS (handle_bar)->button_press_event),
handle_bar);
g_signal_connect_swapped (tool->output_bar, "button-release-event",
G_CALLBACK (GTK_WIDGET_GET_CLASS (handle_bar)->button_release_event),
handle_bar);
g_signal_connect_swapped (tool->output_bar, "motion-notify-event",
G_CALLBACK (GTK_WIDGET_GET_CLASS (handle_bar)->motion_notify_event),
handle_bar);
gimp_handle_bar_connect_events (GIMP_HANDLE_BAR (handle_bar),
tool->output_bar);
/* Horizontal box for levels spin widgets */
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
......
......@@ -350,6 +350,30 @@ gimp_handle_bar_set_adjustment (GimpHandleBar *bar,
gimp_handle_bar_adjustment_changed (bar->slider_adj[handle_no], bar);
}
void
gimp_handle_bar_connect_events (GimpHandleBar *bar,
GtkWidget *event_source)
{
GtkWidgetClass *widget_class;
g_return_if_fail (GIMP_IS_HANDLE_BAR (bar));
g_return_if_fail (GTK_IS_WIDGET (event_source));
widget_class = GTK_WIDGET_GET_CLASS (bar);
g_signal_connect_object (event_source, "button-press-event",
G_CALLBACK (widget_class->button_press_event),
bar, G_CONNECT_SWAPPED);
g_signal_connect_object (event_source, "button-release-event",
G_CALLBACK (widget_class->button_release_event),
bar, G_CONNECT_SWAPPED);
g_signal_connect_object (event_source, "motion-notify-event",
G_CALLBACK (widget_class->motion_notify_event),
bar, G_CONNECT_SWAPPED);
}
/* private functions */
......
......@@ -57,5 +57,8 @@ void gimp_handle_bar_set_adjustment (GimpHandleBar *bar,
gint handle_no,
GtkAdjustment *adjustment);
void gimp_handle_bar_connect_events (GimpHandleBar *bar,
GtkWidget *event_source);
#endif /* __GIMP_HANDLE_BAR_H__ */
......@@ -133,17 +133,8 @@ gimp_histogram_box_init (GimpHistogramBox *box)
gtk_box_pack_start (GTK_BOX (vbox2), bar, FALSE, FALSE, 0);
gtk_widget_show (bar);
g_signal_connect_swapped (box->color_bar, "button-press-event",
G_CALLBACK (GTK_WIDGET_GET_CLASS (box->slider_bar)->button_press_event),
box->slider_bar);
g_signal_connect_swapped (box->color_bar, "button-release-event",
G_CALLBACK (GTK_WIDGET_GET_CLASS (box->slider_bar)->button_release_event),
box->slider_bar);
g_signal_connect_swapped (box->color_bar, "motion-notify-event",
G_CALLBACK (GTK_WIDGET_GET_CLASS (box->slider_bar)->motion_notify_event),
box->slider_bar);
gimp_handle_bar_connect_events (GIMP_HANDLE_BAR (box->slider_bar),
box->color_bar);
/* The range selection */
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment