comparison src/gtkutil.c @ 111781:0bd93f14fcb6

Fix error in last merge. src/gtkutil.c (menubar_map_cb): Use xg_height_or_width_changed.
author Chong Yidong <cyd@stupidchicken.com>
date Tue, 30 Nov 2010 12:01:18 -0500
parents 141d3f14d8c3
children 968255ee954a
comparison
equal deleted inserted replaced
111780:e235f9dbb282 111781:0bd93f14fcb6
557 gpointer user_data) 557 gpointer user_data)
558 { 558 {
559 FRAME_PTR f = (FRAME_PTR) user_data; 559 FRAME_PTR f = (FRAME_PTR) user_data;
560 struct x_output *x = f->output_data.x; 560 struct x_output *x = f->output_data.x;
561 GtkWidget *top = gtk_widget_get_toplevel (x->ttip_lbl); 561 GtkWidget *top = gtk_widget_get_toplevel (x->ttip_lbl);
562 562
563 if (! top || ! GTK_IS_WINDOW (top)) 563 if (! top || ! GTK_IS_WINDOW (top))
564 gtk_widget_hide (previous_toplevel); 564 gtk_widget_hide (previous_toplevel);
565 } 565 }
566 566
567 /* Callback called when Gtk+ thinks a tooltip should be displayed. 567 /* Callback called when Gtk+ thinks a tooltip should be displayed.
578 GtkTooltip *tooltip, 578 GtkTooltip *tooltip,
579 gpointer user_data) 579 gpointer user_data)
580 { 580 {
581 FRAME_PTR f = (FRAME_PTR) user_data; 581 FRAME_PTR f = (FRAME_PTR) user_data;
582 struct x_output *x = f->output_data.x; 582 struct x_output *x = f->output_data.x;
583 if (x->ttip_widget == NULL) 583 if (x->ttip_widget == NULL)
584 { 584 {
585 g_object_set (G_OBJECT (widget), "has-tooltip", FALSE, NULL); 585 g_object_set (G_OBJECT (widget), "has-tooltip", FALSE, NULL);
586 x->ttip_widget = tooltip; 586 x->ttip_widget = tooltip;
587 g_object_ref (G_OBJECT (tooltip)); 587 g_object_ref (G_OBJECT (tooltip));
588 x->ttip_lbl = gtk_label_new (""); 588 x->ttip_lbl = gtk_label_new ("");
631 widget = GTK_WIDGET (x->ttip_lbl); 631 widget = GTK_WIDGET (x->ttip_lbl);
632 gwin = gtk_widget_get_window (GTK_WIDGET (x->ttip_window)); 632 gwin = gtk_widget_get_window (GTK_WIDGET (x->ttip_window));
633 screen = gdk_drawable_get_screen (gwin); 633 screen = gdk_drawable_get_screen (gwin);
634 settings = gtk_settings_get_for_screen (screen); 634 settings = gtk_settings_get_for_screen (screen);
635 g_object_get (settings, "gtk-enable-tooltips", &tt_enabled, NULL); 635 g_object_get (settings, "gtk-enable-tooltips", &tt_enabled, NULL);
636 if (tt_enabled) 636 if (tt_enabled)
637 { 637 {
638 g_object_set (settings, "gtk-enable-tooltips", FALSE, NULL); 638 g_object_set (settings, "gtk-enable-tooltips", FALSE, NULL);
639 /* Record that we disabled it so it can be enabled again. */ 639 /* Record that we disabled it so it can be enabled again. */
640 g_object_set_data (G_OBJECT (x->ttip_window), "restore-tt", 640 g_object_set_data (G_OBJECT (x->ttip_window), "restore-tt",
641 (gpointer)f); 641 (gpointer)f);
642 } 642 }
643 643
644 /* Prevent Gtk+ from hiding tooltip on mouse move and such. */ 644 /* Prevent Gtk+ from hiding tooltip on mouse move and such. */
645 g_object_set_data (G_OBJECT 645 g_object_set_data (G_OBJECT
646 (gtk_widget_get_display (GTK_WIDGET (x->ttip_window))), 646 (gtk_widget_get_display (GTK_WIDGET (x->ttip_window))),
647 "gdk-display-current-tooltip", NULL); 647 "gdk-display-current-tooltip", NULL);
648 648
652 652
653 gtk_tooltip_set_text (x->ttip_widget, SDATA (encoded_string)); 653 gtk_tooltip_set_text (x->ttip_widget, SDATA (encoded_string));
654 gtk_widget_size_request (GTK_WIDGET (x->ttip_window), &req); 654 gtk_widget_size_request (GTK_WIDGET (x->ttip_window), &req);
655 if (width) *width = req.width; 655 if (width) *width = req.width;
656 if (height) *height = req.height; 656 if (height) *height = req.height;
657 657
658 UNBLOCK_INPUT; 658 UNBLOCK_INPUT;
659 659
660 return 1; 660 return 1;
661 #endif /* USE_GTK_TOOLTIP */ 661 #endif /* USE_GTK_TOOLTIP */
662 } 662 }
799 gdk_window_get_geometry (gtk_widget_get_window (FRAME_GTK_WIDGET (f)), 799 gdk_window_get_geometry (gtk_widget_get_window (FRAME_GTK_WIDGET (f)),
800 0, 0, 800 0, 0,
801 &pixelwidth, &pixelheight, 0); 801 &pixelwidth, &pixelheight, 0);
802 else return; 802 else return;
803 } 803 }
804 804
805 805
806 rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, pixelheight); 806 rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, pixelheight);
807 columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, pixelwidth); 807 columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, pixelwidth);
808 808
809 if (columns != FRAME_COLS (f) 809 if (columns != FRAME_COLS (f)
1073 #ifdef USE_GTK_TOOLTIP 1073 #ifdef USE_GTK_TOOLTIP
1074 /* Steal a tool tip window we can move ourselves. */ 1074 /* Steal a tool tip window we can move ourselves. */
1075 f->output_data.x->ttip_widget = 0; 1075 f->output_data.x->ttip_widget = 0;
1076 f->output_data.x->ttip_lbl = 0; 1076 f->output_data.x->ttip_lbl = 0;
1077 f->output_data.x->ttip_window = 0; 1077 f->output_data.x->ttip_window = 0;
1078 gtk_widget_set_tooltip_text (wtop, "Dummy text"); 1078 gtk_widget_set_tooltip_text (wtop, "Dummy text");
1079 g_signal_connect (wtop, "query-tooltip", G_CALLBACK (qttip_cb), f); 1079 g_signal_connect (wtop, "query-tooltip", G_CALLBACK (qttip_cb), f);
1080 #endif 1080 #endif
1081 1081
1082 { 1082 {
1083 GdkScreen *screen = gtk_widget_get_screen (wtop); 1083 GdkScreen *screen = gtk_widget_get_screen (wtop);
1452 if (dd->w) gtk_widget_destroy (dd->w); 1452 if (dd->w) gtk_widget_destroy (dd->w);
1453 if (dd->timerid != 0) g_source_remove (dd->timerid); 1453 if (dd->timerid != 0) g_source_remove (dd->timerid);
1454 1454
1455 g_main_loop_quit (dd->loop); 1455 g_main_loop_quit (dd->loop);
1456 g_main_loop_unref (dd->loop); 1456 g_main_loop_unref (dd->loop);
1457 1457
1458 UNBLOCK_INPUT; 1458 UNBLOCK_INPUT;
1459 1459
1460 return Qnil; 1460 return Qnil;
1461 } 1461 }
1462 1462
1480 dd); 1480 dd);
1481 } 1481 }
1482 return FALSE; 1482 return FALSE;
1483 } 1483 }
1484 1484
1485 1485
1486 /* Pops up a modal dialog W and waits for response. 1486 /* Pops up a modal dialog W and waits for response.
1487 We don't use gtk_dialog_run because we want to process emacs timers. 1487 We don't use gtk_dialog_run because we want to process emacs timers.
1488 The dialog W is not destroyed when this function returns. */ 1488 The dialog W is not destroyed when this function returns. */
1489 1489
1490 static int 1490 static int
1514 1514
1515 record_unwind_protect (pop_down_dialog, make_save_value (&dd, 0)); 1515 record_unwind_protect (pop_down_dialog, make_save_value (&dd, 0));
1516 1516
1517 (void) xg_maybe_add_timer (&dd); 1517 (void) xg_maybe_add_timer (&dd);
1518 g_main_loop_run (dd.loop); 1518 g_main_loop_run (dd.loop);
1519 1519
1520 dd.w = 0; 1520 dd.w = 0;
1521 unbind_to (count, Qnil); 1521 unbind_to (count, Qnil);
1522 1522
1523 return dd.response; 1523 return dd.response;
1524 } 1524 }
3082 menubar_map_cb (GtkWidget *w, gpointer user_data) 3082 menubar_map_cb (GtkWidget *w, gpointer user_data)
3083 { 3083 {
3084 GtkRequisition req; 3084 GtkRequisition req;
3085 FRAME_PTR f = (FRAME_PTR) user_data; 3085 FRAME_PTR f = (FRAME_PTR) user_data;
3086 gtk_widget_size_request (w, &req); 3086 gtk_widget_size_request (w, &req);
3087 if (FRAME_MENUBAR_HEIGHT (f) != req.height) 3087 if (FRAME_MENUBAR_HEIGHT (f) != req.height)
3088 { 3088 {
3089 FRAME_MENUBAR_HEIGHT (f) = req.height; 3089 FRAME_MENUBAR_HEIGHT (f) = req.height;
3090 xg_height_changed (f); 3090 xg_height_or_width_changed (f);
3091 } 3091 }
3092 } 3092 }
3093 3093
3094 /* Recompute all the widgets of frame F, when the menu bar has been 3094 /* Recompute all the widgets of frame F, when the menu bar has been
3095 changed. Value is non-zero if widgets were updated. */ 3095 changed. Value is non-zero if widgets were updated. */
3366 (gpointer) bar); 3366 (gpointer) bar);
3367 g_signal_connect (G_OBJECT (wscroll), 3367 g_signal_connect (G_OBJECT (wscroll),
3368 "button-release-event", 3368 "button-release-event",
3369 end_callback, 3369 end_callback,
3370 (gpointer) bar); 3370 (gpointer) bar);
3371 3371
3372 /* The scroll bar widget does not draw on a window of its own. Instead 3372 /* The scroll bar widget does not draw on a window of its own. Instead
3373 it draws on the parent window, in this case the edit widget. So 3373 it draws on the parent window, in this case the edit widget. So
3374 whenever the edit widget is cleared, the scroll bar needs to redraw 3374 whenever the edit widget is cleared, the scroll bar needs to redraw
3375 also, which causes flicker. Put an event box between the edit widget 3375 also, which causes flicker. Put an event box between the edit widget
3376 and the scroll bar, so the scroll bar instead draws itself on the 3376 and the scroll bar, so the scroll bar instead draws itself on the
3455 above. */ 3455 above. */
3456 x_clear_area (FRAME_X_DISPLAY (f), 3456 x_clear_area (FRAME_X_DISPLAY (f),
3457 FRAME_X_WINDOW (f), 3457 FRAME_X_WINDOW (f),
3458 oldx, oldy, oldw, oldh, 0); 3458 oldx, oldy, oldw, oldh, 0);
3459 } 3459 }
3460 3460
3461 /* GTK does not redraw until the main loop is entered again, but 3461 /* GTK does not redraw until the main loop is entered again, but
3462 if there are no X events pending we will not enter it. So we sync 3462 if there are no X events pending we will not enter it. So we sync
3463 here to get some events. */ 3463 here to get some events. */
3464 3464
3465 x_sync (f); 3465 x_sync (f);
3466 SET_FRAME_GARBAGED (f); 3466 SET_FRAME_GARBAGED (f);
3467 cancel_mouse_face (f); 3467 cancel_mouse_face (f);
3468 } 3468 }
3469 } 3469 }
3574 { 3574 {
3575 /* If we are releasing or moving the scroll bar, it has the grab. */ 3575 /* If we are releasing or moving the scroll bar, it has the grab. */
3576 GtkWidget *w = gtk_grab_get_current (); 3576 GtkWidget *w = gtk_grab_get_current ();
3577 retval = w != 0 && GTK_IS_SCROLLBAR (w); 3577 retval = w != 0 && GTK_IS_SCROLLBAR (w);
3578 } 3578 }
3579 3579
3580 return retval; 3580 return retval;
3581 } 3581 }
3582 3582
3583 3583
3584 3584
3662 /* Convert between the modifier bits GDK uses and the modifier bits 3662 /* Convert between the modifier bits GDK uses and the modifier bits
3663 Emacs uses. This assumes GDK and X masks are the same, which they are when 3663 Emacs uses. This assumes GDK and X masks are the same, which they are when
3664 this is written. */ 3664 this is written. */
3665 event.modifiers = x_x_to_emacs_modifiers (FRAME_X_DISPLAY_INFO (f), mod); 3665 event.modifiers = x_x_to_emacs_modifiers (FRAME_X_DISPLAY_INFO (f), mod);
3666 kbd_buffer_store_event (&event); 3666 kbd_buffer_store_event (&event);
3667 3667
3668 /* Return focus to the frame after we have clicked on a detached 3668 /* Return focus to the frame after we have clicked on a detached
3669 tool bar button. */ 3669 tool bar button. */
3670 Fx_focus_frame (frame); 3670 Fx_focus_frame (frame);
3671 } 3671 }
3672 3672
3699 GdkEventCrossing *event, 3699 GdkEventCrossing *event,
3700 gpointer client_data) 3700 gpointer client_data)
3701 { 3701 {
3702 GtkWidget *wbutton = GTK_WIDGET (g_object_get_data (G_OBJECT (w), 3702 GtkWidget *wbutton = GTK_WIDGET (g_object_get_data (G_OBJECT (w),
3703 XG_TOOL_BAR_PROXY_BUTTON)); 3703 XG_TOOL_BAR_PROXY_BUTTON));
3704 3704
3705 return xg_tool_bar_help_callback (wbutton, event, client_data); 3705 return xg_tool_bar_help_callback (wbutton, event, client_data);
3706 } 3706 }
3707 3707
3708 static GtkWidget * 3708 static GtkWidget *
3709 xg_get_tool_bar_widgets (GtkWidget *vb, GtkWidget **wimage) 3709 xg_get_tool_bar_widgets (GtkWidget *vb, GtkWidget **wimage)
3802 g_signal_connect (G_OBJECT (wmenuitem), 3802 g_signal_connect (G_OBJECT (wmenuitem),
3803 "activate", 3803 "activate",
3804 G_CALLBACK (xg_tool_bar_proxy_callback), 3804 G_CALLBACK (xg_tool_bar_proxy_callback),
3805 user_data); 3805 user_data);
3806 3806
3807 3807
3808 g_object_set_data (G_OBJECT (wmenuitem), XG_TOOL_BAR_PROXY_BUTTON, 3808 g_object_set_data (G_OBJECT (wmenuitem), XG_TOOL_BAR_PROXY_BUTTON,
3809 (gpointer) wbutton); 3809 (gpointer) wbutton);
3810 gtk_tool_item_set_proxy_menu_item (toolitem, "Emacs toolbar item", wmenuitem); 3810 gtk_tool_item_set_proxy_menu_item (toolitem, "Emacs toolbar item", wmenuitem);
3811 gtk_widget_set_sensitive (wmenuitem, 3811 gtk_widget_set_sensitive (wmenuitem,
3812 gtk_widget_get_sensitive (GTK_WIDGET (wbutton))); 3812 gtk_widget_get_sensitive (GTK_WIDGET (wbutton)));
4000 G_CALLBACK (xg_tool_bar_attach_callback), f); 4000 G_CALLBACK (xg_tool_bar_attach_callback), f);
4001 gtk_container_add (GTK_CONTAINER (x->handlebox_widget), 4001 gtk_container_add (GTK_CONTAINER (x->handlebox_widget),
4002 x->toolbar_widget); 4002 x->toolbar_widget);
4003 } 4003 }
4004 4004
4005 if (into_hbox) 4005 if (into_hbox)
4006 { 4006 {
4007 gtk_handle_box_set_handle_position (GTK_HANDLE_BOX (x->handlebox_widget), 4007 gtk_handle_box_set_handle_position (GTK_HANDLE_BOX (x->handlebox_widget),
4008 GTK_POS_TOP); 4008 GTK_POS_TOP);
4009 gtk_box_pack_start (GTK_BOX (x->hbox_widget), x->handlebox_widget, 4009 gtk_box_pack_start (GTK_BOX (x->hbox_widget), x->handlebox_widget,
4010 FALSE, FALSE, 0); 4010 FALSE, FALSE, 0);
4091 { 4091 {
4092 GtkToolItem *ti = gtk_tool_item_new (); 4092 GtkToolItem *ti = gtk_tool_item_new ();
4093 Lisp_Object style = Ftool_bar_get_system_style (); 4093 Lisp_Object style = Ftool_bar_get_system_style ();
4094 int both_horiz = EQ (style, Qboth_horiz); 4094 int both_horiz = EQ (style, Qboth_horiz);
4095 int text_image = EQ (style, Qtext_image_horiz); 4095 int text_image = EQ (style, Qtext_image_horiz);
4096 4096
4097 GtkWidget *vb = both_horiz || text_image 4097 GtkWidget *vb = both_horiz || text_image
4098 ? gtk_hbox_new (FALSE, 0) : gtk_vbox_new (FALSE, 0); 4098 ? gtk_hbox_new (FALSE, 0) : gtk_vbox_new (FALSE, 0);
4099 GtkWidget *wb = gtk_button_new (); 4099 GtkWidget *wb = gtk_button_new ();
4100 GtkWidget *weventbox = gtk_event_box_new (); 4100 GtkWidget *weventbox = gtk_event_box_new ();
4101 4101
4145 g_signal_connect (wb, "button-release-event", 4145 g_signal_connect (wb, "button-release-event",
4146 G_CALLBACK (xg_tool_bar_button_cb), 4146 G_CALLBACK (xg_tool_bar_button_cb),
4147 NULL); 4147 NULL);
4148 4148
4149 g_object_set_data (G_OBJECT (wb), XG_FRAME_DATA, (gpointer)f); 4149 g_object_set_data (G_OBJECT (wb), XG_FRAME_DATA, (gpointer)f);
4150 4150
4151 /* Use enter/leave notify to show help. We use the events 4151 /* Use enter/leave notify to show help. We use the events
4152 rather than the GtkButton specific signals "enter" and 4152 rather than the GtkButton specific signals "enter" and
4153 "leave", so we can have only one callback. The event 4153 "leave", so we can have only one callback. The event
4154 will tell us what kind of event it is. */ 4154 will tell us what kind of event it is. */
4155 /* The EMACS_INT cast avoids a warning. */ 4155 /* The EMACS_INT cast avoids a warning. */
4160 g_signal_connect (G_OBJECT (weventbox), 4160 g_signal_connect (G_OBJECT (weventbox),
4161 "leave-notify-event", 4161 "leave-notify-event",
4162 G_CALLBACK (xg_tool_bar_help_callback), 4162 G_CALLBACK (xg_tool_bar_help_callback),
4163 (gpointer) (EMACS_INT) i); 4163 (gpointer) (EMACS_INT) i);
4164 } 4164 }
4165 4165
4166 if (wbutton) *wbutton = wb; 4166 if (wbutton) *wbutton = wb;
4167 4167
4168 return ti; 4168 return ti;
4169 } 4169 }
4170 4170
4246 x->handlebox_widget, 4246 x->handlebox_widget,
4247 "position", &pos, NULL); 4247 "position", &pos, NULL);
4248 if (pos == 0 || (pos == 1 && x->menubar_widget)) nt = req.height; 4248 if (pos == 0 || (pos == 1 && x->menubar_widget)) nt = req.height;
4249 else nb = req.height; 4249 else nb = req.height;
4250 } 4250 }
4251 4251
4252 if (nl != FRAME_TOOLBAR_LEFT_WIDTH (f) 4252 if (nl != FRAME_TOOLBAR_LEFT_WIDTH (f)
4253 || nr != FRAME_TOOLBAR_RIGHT_WIDTH (f) 4253 || nr != FRAME_TOOLBAR_RIGHT_WIDTH (f)
4254 || nt != FRAME_TOOLBAR_TOP_HEIGHT (f) 4254 || nt != FRAME_TOOLBAR_TOP_HEIGHT (f)
4255 || nb != FRAME_TOOLBAR_BOTTOM_HEIGHT (f)) 4255 || nb != FRAME_TOOLBAR_BOTTOM_HEIGHT (f))
4256 { 4256 {
4312 if (! x->toolbar_widget) 4312 if (! x->toolbar_widget)
4313 xg_create_tool_bar (f); 4313 xg_create_tool_bar (f);
4314 4314
4315 wtoolbar = GTK_TOOLBAR (x->toolbar_widget); 4315 wtoolbar = GTK_TOOLBAR (x->toolbar_widget);
4316 dir = gtk_widget_get_direction (GTK_WIDGET (wtoolbar)); 4316 dir = gtk_widget_get_direction (GTK_WIDGET (wtoolbar));
4317 4317
4318 for (i = 0; i < f->n_tool_bar_items; ++i) 4318 for (i = 0; i < f->n_tool_bar_items; ++i)
4319 { 4319 {
4320 int enabled_p = !NILP (PROP (TOOL_BAR_ITEM_ENABLED_P)); 4320 int enabled_p = !NILP (PROP (TOOL_BAR_ITEM_ENABLED_P));
4321 int selected_p = !NILP (PROP (TOOL_BAR_ITEM_SELECTED_P)); 4321 int selected_p = !NILP (PROP (TOOL_BAR_ITEM_SELECTED_P));
4322 int idx; 4322 int idx;
4558 { 4558 {
4559 int is_packed = x->handlebox_widget != 0; 4559 int is_packed = x->handlebox_widget != 0;
4560 BLOCK_INPUT; 4560 BLOCK_INPUT;
4561 /* We may have created the toolbar_widget in xg_create_tool_bar, but 4561 /* We may have created the toolbar_widget in xg_create_tool_bar, but
4562 not the x->handlebox_widget which is created in xg_pack_tool_bar. */ 4562 not the x->handlebox_widget which is created in xg_pack_tool_bar. */
4563 if (is_packed) 4563 if (is_packed)
4564 { 4564 {
4565 if (x->toolbar_in_hbox) 4565 if (x->toolbar_in_hbox)
4566 gtk_container_remove (GTK_CONTAINER (x->hbox_widget), 4566 gtk_container_remove (GTK_CONTAINER (x->hbox_widget),
4567 x->handlebox_widget); 4567 x->handlebox_widget);
4568 else 4568 else