From f098b121caf14e743c05e8ea1f015a78aace5d15 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20Dj=C3=A4rv?= Date: Mon, 17 Feb 2003 18:39:53 +0000 Subject: [PATCH] * gtkutil.c (xg_tool_bar_expose_callback): New function. (xg_create_tool_bar): Force style of tool bar to be horizontal with icons. Set name of tool bar to emacs-toolbar. (update_frame_tool_bar): Connect expose event to xg_tool_bar_expose_callback. --- src/ChangeLog | 8 ++++++++ src/gtkutil.c | 42 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/ChangeLog b/src/ChangeLog index 57d144c63bc..f9d0f56503e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2003-02-17 Jan Dj,Ad(Brv + + * gtkutil.c (xg_tool_bar_expose_callback): New function. + (xg_create_tool_bar): Force style of tool bar to be horizontal with + icons. Set name of tool bar to emacs-toolbar. + (update_frame_tool_bar): Connect expose event to + xg_tool_bar_expose_callback. + 2003-02-17 Richard M. Stallman * keyboard.c (this_command_key_count_reset): New variable. diff --git a/src/gtkutil.c b/src/gtkutil.c index 6b92779cbf6..609243912bd 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c @@ -2666,6 +2666,26 @@ xg_tool_bar_help_callback (w, event, client_data) } +/* This callback is called when a tool bar item shall be redrawn. + It modifies the expose event so that the GtkImage widget redraws the + whole image. This to overcome a bug that makes GtkImage draw the image + in the wrong place when it tries to redraw just a part of the image. + W is the GtkImage to be redrawn. + EVENT is the expose event for W. + CLIENT_DATA is unused. + + 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; +{ + event->area.x = event->area.y = 0; + event->area.width = event->area.height = 1000; + return FALSE; +} + static void xg_create_tool_bar (f) FRAME_PTR f; @@ -2685,6 +2705,19 @@ xg_create_tool_bar (f) gtk_box_reorder_child (GTK_BOX (x->vbox_widget), x->handlebox_widget, vbox_pos); + gtk_widget_set_name (x->toolbar_widget, "emacs-toolbar"); + + /* We only have icons, so override any user setting. We could + use the caption property of the toolbar item (see update_frame_tool_bar + below), but some of those strings are long, making the toolbar so + long it does not fit on the screen. The GtkToolbar widget makes every + item equal size, so the longest caption determine the size of every + tool bar item. I think the creators of the GtkToolbar widget + counted on 4 or 5 character long strings. */ + gtk_toolbar_set_style (GTK_TOOLBAR (x->toolbar_widget), GTK_TOOLBAR_ICONS); + gtk_toolbar_set_orientation (GTK_TOOLBAR (x->toolbar_widget), + GTK_ORIENTATION_HORIZONTAL); + g_signal_connect (G_OBJECT (x->handlebox_widget), "child-detached", G_CALLBACK (xg_tool_bar_detach_callback), f); g_signal_connect (G_OBJECT (x->handlebox_widget), "child-attached", @@ -2736,7 +2769,7 @@ update_frame_tool_bar (f) struct image *img; Lisp_Object image; GtkWidget *wicon = iter ? GTK_WIDGET (iter->data) : 0; - + if (iter) iter = g_list_next (iter); /* If image is a vector, choose the image according to the @@ -2794,6 +2827,13 @@ update_frame_tool_bar (f) g_object_set_data (G_OBJECT (w), XG_TOOL_BAR_IMAGE_DATA, (gpointer)img); + /* Catch expose events to overcome an annoying redraw bug, see + comment for xg_tool_bar_expose_callback. */ + g_signal_connect (G_OBJECT (w), + "expose-event", + G_CALLBACK (xg_tool_bar_expose_callback), + 0); + /* We must set sensitive on the button that is the parent of the GtkImage parent. Go upwards until we find the button. */ while (! GTK_IS_BUTTON (w)) -- 2.39.2