From 3a8a22fc3d5817b031cb40febeb000bf33d80a60 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20Dj=C3=A4rv?= Date: Sun, 9 Mar 2003 20:41:39 +0000 Subject: [PATCH 1/1] Another fix for BadGC. --- src/gtkutil.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/src/gtkutil.c b/src/gtkutil.c index bae2196965..2c6fb10ccb 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c @@ -2301,6 +2301,27 @@ xg_get_widget_from_map (idx) return 0; } +/* Return the scrollbar id for X Window WID. + Return -1 if WID not in id_to_widget. */ +int +xg_get_scroll_id_for_window (wid) + Window wid; +{ + int idx; + GtkWidget *w; + + w = xg_win_to_widget (wid); + + if (w) + { + for (idx = 0; idx < id_to_widget.max_size; ++idx) + if (id_to_widget.widgets[idx] == w) + return idx; + } + + return -1; +} + /* Callback invoked when scroll bar WIDGET is destroyed. DATA is the index into id_to_widget for WIDGET. We free pointer to last scroll bar value here and remove the index. */ @@ -2381,7 +2402,7 @@ xg_create_scroll_bar (f, bar, scroll_callback, scroll_bar_name) g_signal_connect (G_OBJECT (wscroll), "button-press-event", G_CALLBACK (scroll_bar_button_cb), - (gpointer)1); + 0); g_signal_connect (G_OBJECT (wscroll), "button-release-event", G_CALLBACK (scroll_bar_button_cb), @@ -2676,7 +2697,7 @@ xg_tool_bar_help_callback (w, event, client_data) Returns FALSE to tell GTK to keep processing this event. */ static gboolean -xg_tool_bar_expose_callback (w, event, client_data) +xg_tool_bar_item_expose_callback (w, event, client_data) GtkWidget *w; GdkEventExpose *event; gpointer client_data; @@ -2686,6 +2707,24 @@ xg_tool_bar_expose_callback (w, event, client_data) return FALSE; } +/* This callback is called when a tool bar shall be redrawn. + We need to update the tool bar from here in case the image cache + has deleted the pixmaps used in the tool bar. + W is the GtkToolbar to be redrawn. + EVENT is the expose event for W. + CLIENT_DATA is pointing to the frame for this tool bar. + + Returns FALSE to tell GTK to keep processing this event. */ +static gboolean +xg_tool_bar_expose_callback (w, event, client_data) + GtkWidget *w; + GdkEventExpose *event; + gpointer client_data; +{ + update_frame_tool_bar((FRAME_PTR)client_data); + return FALSE; +} + static void xg_create_tool_bar (f) FRAME_PTR f; @@ -2722,6 +2761,10 @@ xg_create_tool_bar (f) G_CALLBACK (xg_tool_bar_detach_callback), f); g_signal_connect (G_OBJECT (x->handlebox_widget), "child-attached", G_CALLBACK (xg_tool_bar_attach_callback), f); + g_signal_connect (G_OBJECT (x->toolbar_widget), + "expose-event", + G_CALLBACK (xg_tool_bar_expose_callback), + f); gtk_widget_show_all (x->handlebox_widget); @@ -2828,10 +2871,10 @@ update_frame_tool_bar (f) (gpointer)img->pixmap); /* Catch expose events to overcome an annoying redraw bug, see - comment for xg_tool_bar_expose_callback. */ + comment for xg_tool_bar_item_expose_callback. */ g_signal_connect (G_OBJECT (w), "expose-event", - G_CALLBACK (xg_tool_bar_expose_callback), + G_CALLBACK (xg_tool_bar_item_expose_callback), 0); /* We must set sensitive on the button that is the parent -- 2.20.1