diff options
| author | Jan Djärv | 2006-12-31 18:31:49 +0000 |
|---|---|---|
| committer | Jan Djärv | 2006-12-31 18:31:49 +0000 |
| commit | 1e0fe298c297aaab72f1ea39f4a017ac97e77724 (patch) | |
| tree | e33aa4c8853855d0ee2416d37637492232805a5f /src | |
| parent | 13fcde77fb54d616aa83bdc9268e2a92bff4973e (diff) | |
| download | emacs-1e0fe298c297aaab72f1ea39f4a017ac97e77724.tar.gz emacs-1e0fe298c297aaab72f1ea39f4a017ac97e77724.zip | |
(update_frame_tool_bar): Connect create-menu-proxy with
xg_tool_bar_menu_proxy.
(xg_tool_bar_menu_proxy): New function.
(xg_tool_bar_proxy_callback): New function.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 7 | ||||
| -rw-r--r-- | src/gtkutil.c | 96 |
2 files changed, 102 insertions, 1 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 71464f365ae..3dc5a094d4a 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2006-12-31 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> | ||
| 2 | |||
| 3 | * gtkutil.c (update_frame_tool_bar): Connect create-menu-proxy with | ||
| 4 | xg_tool_bar_menu_proxy. | ||
| 5 | (xg_tool_bar_menu_proxy): New function. | ||
| 6 | (xg_tool_bar_proxy_callback): New function. | ||
| 7 | |||
| 1 | 2006-12-30 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> | 8 | 2006-12-30 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> |
| 2 | 9 | ||
| 3 | * gtkutil.c (xg_tool_bar_button_cb): Save last modifier on widget. | 10 | * gtkutil.c (xg_tool_bar_button_cb): Save last modifier on widget. |
diff --git a/src/gtkutil.c b/src/gtkutil.c index b276c9fe7a1..3dcdef2b0ae 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c | |||
| @@ -3350,6 +3350,8 @@ xg_set_toolkit_scroll_bar_thumb (bar, portion, position, whole) | |||
| 3350 | get them. */ | 3350 | get them. */ |
| 3351 | #define XG_TOOL_BAR_LAST_MODIFIER "emacs-tool-bar-modifier" | 3351 | #define XG_TOOL_BAR_LAST_MODIFIER "emacs-tool-bar-modifier" |
| 3352 | 3352 | ||
| 3353 | /* The key for storing the button widget in its proxy menu item. */ | ||
| 3354 | #define XG_TOOL_BAR_PROXY_BUTTON "emacs-tool-bar-proxy-button" | ||
| 3353 | 3355 | ||
| 3354 | static gboolean | 3356 | static gboolean |
| 3355 | xg_tool_bar_button_cb (widget, event, user_data) | 3357 | xg_tool_bar_button_cb (widget, event, user_data) |
| @@ -3406,6 +3408,92 @@ xg_tool_bar_callback (w, client_data) | |||
| 3406 | kbd_buffer_store_event (&event); | 3408 | kbd_buffer_store_event (&event); |
| 3407 | } | 3409 | } |
| 3408 | 3410 | ||
| 3411 | /* Callback function invoked when a tool bar item is pressed in a detached | ||
| 3412 | tool bar or the overflow drop down menu. | ||
| 3413 | We just call xg_tool_bar_callback. | ||
| 3414 | W is the menu item widget that got pressed, | ||
| 3415 | CLIENT_DATA is an integer that is the index of the button in the | ||
| 3416 | tool bar. 0 is the first button. */ | ||
| 3417 | |||
| 3418 | static void | ||
| 3419 | xg_tool_bar_proxy_callback (w, client_data) | ||
| 3420 | GtkWidget *w; | ||
| 3421 | gpointer client_data; | ||
| 3422 | { | ||
| 3423 | GtkWidget *wbutton = GTK_WIDGET (g_object_get_data (G_OBJECT (w), | ||
| 3424 | XG_TOOL_BAR_PROXY_BUTTON)); | ||
| 3425 | xg_tool_bar_callback (wbutton, client_data); | ||
| 3426 | } | ||
| 3427 | |||
| 3428 | /* This callback is called when a tool item should create a proxy item, | ||
| 3429 | such as for the overflow menu. Also called when the tool bar is detached. | ||
| 3430 | If we don't create a proxy menu item, the detached tool bar will be | ||
| 3431 | blank. */ | ||
| 3432 | |||
| 3433 | static gboolean | ||
| 3434 | xg_tool_bar_menu_proxy (toolitem, user_data) | ||
| 3435 | GtkToolItem *toolitem; | ||
| 3436 | gpointer user_data; | ||
| 3437 | { | ||
| 3438 | GtkWidget *weventbox = gtk_bin_get_child (GTK_BIN (toolitem)); | ||
| 3439 | GtkButton *wbutton = GTK_BUTTON (gtk_bin_get_child (GTK_BIN (weventbox))); | ||
| 3440 | GtkWidget *wmenuitem = gtk_image_menu_item_new (); | ||
| 3441 | GtkWidget *wmenuimage; | ||
| 3442 | |||
| 3443 | if (gtk_button_get_use_stock (wbutton)) | ||
| 3444 | wmenuimage = gtk_image_new_from_stock (gtk_button_get_label (wbutton), | ||
| 3445 | GTK_ICON_SIZE_MENU); | ||
| 3446 | else | ||
| 3447 | { | ||
| 3448 | GtkImage *wimage = GTK_IMAGE (gtk_bin_get_child (GTK_BIN (wbutton))); | ||
| 3449 | GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (wbutton)); | ||
| 3450 | GtkImageType store_type = gtk_image_get_storage_type (wimage); | ||
| 3451 | if (store_type == GTK_IMAGE_STOCK) | ||
| 3452 | { | ||
| 3453 | gchar *stock_id; | ||
| 3454 | gtk_image_get_stock (wimage, &stock_id, NULL); | ||
| 3455 | wmenuimage = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_MENU); | ||
| 3456 | } | ||
| 3457 | else if (store_type == GTK_IMAGE_ICON_SET) | ||
| 3458 | { | ||
| 3459 | GtkIconSet *icon_set; | ||
| 3460 | gtk_image_get_icon_set (wimage, &icon_set, NULL); | ||
| 3461 | wmenuimage = gtk_image_new_from_icon_set (icon_set, | ||
| 3462 | GTK_ICON_SIZE_MENU); | ||
| 3463 | } | ||
| 3464 | else if (store_type == GTK_IMAGE_PIXBUF) | ||
| 3465 | { | ||
| 3466 | gint width, height; | ||
| 3467 | |||
| 3468 | if (settings && | ||
| 3469 | gtk_icon_size_lookup_for_settings (settings, GTK_ICON_SIZE_MENU, | ||
| 3470 | &width, &height)) | ||
| 3471 | { | ||
| 3472 | GdkPixbuf *src_pixbuf, *dest_pixbuf; | ||
| 3473 | |||
| 3474 | src_pixbuf = gtk_image_get_pixbuf (wimage); | ||
| 3475 | dest_pixbuf = gdk_pixbuf_scale_simple (src_pixbuf, width, height, | ||
| 3476 | GDK_INTERP_BILINEAR); | ||
| 3477 | |||
| 3478 | wmenuimage = gtk_image_new_from_pixbuf (dest_pixbuf); | ||
| 3479 | } | ||
| 3480 | } | ||
| 3481 | } | ||
| 3482 | if (wmenuimage) | ||
| 3483 | gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (wmenuitem), wmenuimage); | ||
| 3484 | |||
| 3485 | g_signal_connect (G_OBJECT (wmenuitem), | ||
| 3486 | "activate", | ||
| 3487 | GTK_SIGNAL_FUNC (xg_tool_bar_proxy_callback), | ||
| 3488 | user_data); | ||
| 3489 | |||
| 3490 | g_object_set_data (G_OBJECT (wmenuitem), XG_TOOL_BAR_PROXY_BUTTON, | ||
| 3491 | (gpointer) wbutton); | ||
| 3492 | gtk_tool_item_set_proxy_menu_item (toolitem, "Emacs toolbar item", wmenuitem); | ||
| 3493 | |||
| 3494 | return TRUE; | ||
| 3495 | } | ||
| 3496 | |||
| 3409 | /* This callback is called when a tool bar is detached. We must set | 3497 | /* This callback is called when a tool bar is detached. We must set |
| 3410 | the height of the tool bar to zero when this happens so frame sizes | 3498 | the height of the tool bar to zero when this happens so frame sizes |
| 3411 | are correctly calculated. | 3499 | are correctly calculated. |
| @@ -3727,6 +3815,7 @@ update_frame_tool_bar (f) | |||
| 3727 | /* Insert an empty (non-image) button */ | 3815 | /* Insert an empty (non-image) button */ |
| 3728 | weventbox = gtk_event_box_new (); | 3816 | weventbox = gtk_event_box_new (); |
| 3729 | wbutton = gtk_button_new (); | 3817 | wbutton = gtk_button_new (); |
| 3818 | gtk_button_set_focus_on_click (GTK_BUTTON (wbutton), FALSE); | ||
| 3730 | gtk_button_set_relief (GTK_BUTTON (wbutton), GTK_RELIEF_NONE); | 3819 | gtk_button_set_relief (GTK_BUTTON (wbutton), GTK_RELIEF_NONE); |
| 3731 | gtk_container_add (GTK_CONTAINER (weventbox), wbutton); | 3820 | gtk_container_add (GTK_CONTAINER (weventbox), wbutton); |
| 3732 | ti = gtk_tool_item_new (); | 3821 | ti = gtk_tool_item_new (); |
| @@ -3741,6 +3830,7 @@ update_frame_tool_bar (f) | |||
| 3741 | GtkWidget *w = xg_get_image_for_pixmap (f, img, x->widget, NULL); | 3830 | GtkWidget *w = xg_get_image_for_pixmap (f, img, x->widget, NULL); |
| 3742 | gtk_misc_set_padding (GTK_MISC (w), hmargin, vmargin); | 3831 | gtk_misc_set_padding (GTK_MISC (w), hmargin, vmargin); |
| 3743 | wbutton = gtk_button_new (); | 3832 | wbutton = gtk_button_new (); |
| 3833 | gtk_button_set_focus_on_click (GTK_BUTTON (wbutton), FALSE); | ||
| 3744 | gtk_button_set_relief (GTK_BUTTON (wbutton), GTK_RELIEF_NONE); | 3834 | gtk_button_set_relief (GTK_BUTTON (wbutton), GTK_RELIEF_NONE); |
| 3745 | gtk_container_add (GTK_CONTAINER (wbutton), w); | 3835 | gtk_container_add (GTK_CONTAINER (wbutton), w); |
| 3746 | weventbox = gtk_event_box_new (); | 3836 | weventbox = gtk_event_box_new (); |
| @@ -3751,7 +3841,11 @@ update_frame_tool_bar (f) | |||
| 3751 | 3841 | ||
| 3752 | 3842 | ||
| 3753 | /* The EMACS_INT cast avoids a warning. */ | 3843 | /* The EMACS_INT cast avoids a warning. */ |
| 3754 | g_signal_connect (wbutton, "clicked", | 3844 | g_signal_connect (G_OBJECT (ti), "create-menu-proxy", |
| 3845 | GTK_SIGNAL_FUNC (xg_tool_bar_menu_proxy), | ||
| 3846 | (gpointer) (EMACS_INT) i); | ||
| 3847 | |||
| 3848 | g_signal_connect (G_OBJECT (wbutton), "clicked", | ||
| 3755 | GTK_SIGNAL_FUNC (xg_tool_bar_callback), | 3849 | GTK_SIGNAL_FUNC (xg_tool_bar_callback), |
| 3756 | (gpointer) (EMACS_INT) i); | 3850 | (gpointer) (EMACS_INT) i); |
| 3757 | 3851 | ||