Mercurial > emacs
comparison src/gtkutil.c @ 91041:bdb3fe0ba9fa
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (patch 866-879)
- Merge multi-tty branch
- Update from CVS
- Merge from emacs--rel--22
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-257
author | Miles Bader <miles@gnu.org> |
---|---|
date | Thu, 11 Oct 2007 16:22:07 +0000 |
parents | b83d0dadb2a7 5d074ea0e4a2 |
children | 880960b70474 |
comparison
equal
deleted
inserted
replaced
91040:14c4a6aac623 | 91041:bdb3fe0ba9fa |
---|---|
49 Display handling functions | 49 Display handling functions |
50 ***********************************************************************/ | 50 ***********************************************************************/ |
51 | 51 |
52 #ifdef HAVE_GTK_MULTIDISPLAY | 52 #ifdef HAVE_GTK_MULTIDISPLAY |
53 | 53 |
54 /* Gtk does not work well without any display open. Emacs may close | |
55 all its displays. In that case, keep a display around just for | |
56 the purpose of having one. */ | |
57 | |
58 static GdkDisplay *gdpy_def; | |
59 | |
60 | |
54 /* Return the GdkDisplay that corresponds to the X display DPY. */ | 61 /* Return the GdkDisplay that corresponds to the X display DPY. */ |
55 | 62 |
56 static GdkDisplay * | 63 static GdkDisplay * |
57 xg_get_gdk_display (dpy) | 64 xg_get_gdk_display (dpy) |
58 Display *dpy; | 65 Display *dpy; |
145 { | 152 { |
146 new_dpy = dpyinfo->display; | 153 new_dpy = dpyinfo->display; |
147 break; | 154 break; |
148 } | 155 } |
149 | 156 |
150 if (! new_dpy) return; /* Emacs will exit anyway. */ | 157 if (new_dpy) |
151 | 158 gdpy_new = gdk_x11_lookup_xdisplay (new_dpy); |
152 gdpy_new = gdk_x11_lookup_xdisplay (new_dpy); | 159 else |
160 { | |
161 if (!gdpy_def) | |
162 gdpy_def = gdk_display_open (gdk_display_get_name (gdpy)); | |
163 gdpy_new = gdpy_def; | |
164 } | |
165 | |
153 gdk_display_manager_set_default_display (gdk_display_manager_get (), | 166 gdk_display_manager_set_default_display (gdk_display_manager_get (), |
154 gdpy_new); | 167 gdpy_new); |
155 } | 168 } |
156 | 169 |
157 /* GTK 2.2-2.8 has a bug that makes gdk_display_close crash (bug | 170 /* GTK 2.2-2.8 has a bug that makes gdk_display_close crash (bug |
334 GtkImage *old_widget; | 347 GtkImage *old_widget; |
335 { | 348 { |
336 GdkPixmap *gpix; | 349 GdkPixmap *gpix; |
337 GdkPixmap *gmask; | 350 GdkPixmap *gmask; |
338 GdkDisplay *gdpy; | 351 GdkDisplay *gdpy; |
352 GdkColormap *cmap; | |
353 GdkPixbuf *icon_buf; | |
339 | 354 |
340 /* If we have a file, let GTK do all the image handling. | 355 /* If we have a file, let GTK do all the image handling. |
341 This seems to be the only way to make insensitive and activated icons | 356 This seems to be the only way to make insensitive and activated icons |
342 look good in all cases. */ | 357 look good in all cases. */ |
343 Lisp_Object specified_file = file_for_image (img->spec); | 358 Lisp_Object specified_file = file_for_image (img->spec); |
364 | 379 |
365 gdpy = gdk_x11_lookup_xdisplay (FRAME_X_DISPLAY (f)); | 380 gdpy = gdk_x11_lookup_xdisplay (FRAME_X_DISPLAY (f)); |
366 gpix = gdk_pixmap_foreign_new_for_display (gdpy, img->pixmap); | 381 gpix = gdk_pixmap_foreign_new_for_display (gdpy, img->pixmap); |
367 gmask = img->mask ? gdk_pixmap_foreign_new_for_display (gdpy, img->mask) : 0; | 382 gmask = img->mask ? gdk_pixmap_foreign_new_for_display (gdpy, img->mask) : 0; |
368 | 383 |
369 if (x_screen_planes (f) > 8 || x_screen_planes (f) == 1) | 384 /* This is a workaround to make icons look good on pseudo color |
370 { | 385 displays. Apparently GTK expects the images to have an alpha |
371 if (! old_widget) | 386 channel. If they don't, insensitive and activated icons will |
372 old_widget = GTK_IMAGE (gtk_image_new_from_pixmap (gpix, gmask)); | 387 look bad. This workaround does not work on monochrome displays, |
373 else | 388 and is strictly not needed on true color/static color displays (i.e. |
374 gtk_image_set_from_pixmap (old_widget, gpix, gmask); | 389 16 bits and higher). But we do it anyway so we get a pixbuf that is |
375 } | 390 not associated with the img->pixmap. The img->pixmap may be removed |
391 by clearing the image cache and then the tool bar redraw fails, since | |
392 Gtk+ assumes the pixmap is always there. */ | |
393 cmap = gtk_widget_get_colormap (widget); | |
394 icon_buf = xg_get_pixbuf_from_pix_and_mask (gpix, gmask, cmap); | |
395 | |
396 if (! old_widget) | |
397 old_widget = GTK_IMAGE (gtk_image_new_from_pixbuf (icon_buf)); | |
376 else | 398 else |
377 { | 399 gtk_image_set_from_pixbuf (old_widget, icon_buf); |
378 | 400 |
379 /* This is a workaround to make icons look good on pseudo color | 401 g_object_unref (G_OBJECT (icon_buf)); |
380 displays. Apparently GTK expects the images to have an alpha | |
381 channel. If they don't, insensitive and activated icons will | |
382 look bad. This workaround does not work on monochrome displays, | |
383 and is not needed on true color/static color displays (i.e. | |
384 16 bits and higher). */ | |
385 GdkColormap *cmap = gtk_widget_get_colormap (widget); | |
386 GdkPixbuf *icon_buf = xg_get_pixbuf_from_pix_and_mask (gpix, gmask, cmap); | |
387 | |
388 if (! old_widget) | |
389 old_widget = GTK_IMAGE (gtk_image_new_from_pixbuf (icon_buf)); | |
390 else | |
391 gtk_image_set_from_pixbuf (old_widget, icon_buf); | |
392 | |
393 g_object_unref (G_OBJECT (icon_buf)); | |
394 } | |
395 | 402 |
396 g_object_unref (G_OBJECT (gpix)); | 403 g_object_unref (G_OBJECT (gpix)); |
397 if (gmask) g_object_unref (G_OBJECT (gmask)); | 404 if (gmask) g_object_unref (G_OBJECT (gmask)); |
398 | 405 |
399 return GTK_WIDGET (old_widget); | 406 return GTK_WIDGET (old_widget); |
872 gtk_widget_realize (wfixed); | 879 gtk_widget_realize (wfixed); |
873 FRAME_X_WINDOW (f) = GTK_WIDGET_TO_X_WIN (wfixed); | 880 FRAME_X_WINDOW (f) = GTK_WIDGET_TO_X_WIN (wfixed); |
874 | 881 |
875 /* Since GTK clears its window by filling with the background color, | 882 /* Since GTK clears its window by filling with the background color, |
876 we must keep X and GTK background in sync. */ | 883 we must keep X and GTK background in sync. */ |
877 xg_pix_to_gcolor (wfixed, f->output_data.x->background_pixel, &bg); | 884 xg_pix_to_gcolor (wfixed, FRAME_BACKGROUND_PIXEL (f), &bg); |
878 gtk_widget_modify_bg (wfixed, GTK_STATE_NORMAL, &bg); | 885 gtk_widget_modify_bg (wfixed, GTK_STATE_NORMAL, &bg); |
879 | 886 |
880 /* Also, do not let any background pixmap to be set, this looks very | 887 /* Also, do not let any background pixmap to be set, this looks very |
881 bad as Emacs overwrites the background pixmap with its own idea | 888 bad as Emacs overwrites the background pixmap with its own idea |
882 of background color. */ | 889 of background color. */ |
1410 | 1417 |
1411 if (default_filename) | 1418 if (default_filename) |
1412 { | 1419 { |
1413 Lisp_Object file; | 1420 Lisp_Object file; |
1414 struct gcpro gcpro1; | 1421 struct gcpro gcpro1; |
1422 char *utf8_filename; | |
1415 GCPRO1 (file); | 1423 GCPRO1 (file); |
1416 char *utf8_filename; | |
1417 | 1424 |
1418 file = build_string (default_filename); | 1425 file = build_string (default_filename); |
1419 | 1426 |
1420 /* File chooser does not understand ~/... in the file name. It must be | 1427 /* File chooser does not understand ~/... in the file name. It must be |
1421 an absolute name starting with /. */ | 1428 an absolute name starting with /. */ |
1778 popping down a menu is seen by Emacs (see xg_process_timeouts above). | 1785 popping down a menu is seen by Emacs (see xg_process_timeouts above). |
1779 W is the widget that does the grab (not used). | 1786 W is the widget that does the grab (not used). |
1780 UNGRAB_P is TRUE if this is an ungrab, FALSE if it is a grab. | 1787 UNGRAB_P is TRUE if this is an ungrab, FALSE if it is a grab. |
1781 CLIENT_DATA is NULL (not used). */ | 1788 CLIENT_DATA is NULL (not used). */ |
1782 | 1789 |
1790 /* Keep track of total number of grabs. */ | |
1791 static int menu_grab_callback_cnt; | |
1792 | |
1783 static void | 1793 static void |
1784 menu_grab_callback (GtkWidget *widget, | 1794 menu_grab_callback (GtkWidget *widget, |
1785 gboolean ungrab_p, | 1795 gboolean ungrab_p, |
1786 gpointer client_data) | 1796 gpointer client_data) |
1787 { | 1797 { |
1788 /* Keep track of total number of grabs. */ | 1798 if (ungrab_p) menu_grab_callback_cnt--; |
1789 static int cnt; | 1799 else menu_grab_callback_cnt++; |
1790 | 1800 |
1791 if (ungrab_p) cnt--; | 1801 if (menu_grab_callback_cnt > 0 && ! xg_timer) xg_start_timer (); |
1792 else cnt++; | 1802 else if (menu_grab_callback_cnt == 0 && xg_timer) xg_stop_timer (); |
1793 | |
1794 if (cnt > 0 && ! xg_timer) xg_start_timer (); | |
1795 else if (cnt == 0 && xg_timer) xg_stop_timer (); | |
1796 } | 1803 } |
1797 | 1804 |
1798 /* Make a GTK widget that contains both UTF8_LABEL and UTF8_KEY (both | 1805 /* Make a GTK widget that contains both UTF8_LABEL and UTF8_KEY (both |
1799 must be non-NULL) and can be inserted into a menu item. | 1806 must be non-NULL) and can be inserted into a menu item. |
1800 | 1807 |
1888 } | 1895 } |
1889 | 1896 |
1890 /* Return non-zero if LABEL specifies a separator (GTK only has one | 1897 /* Return non-zero if LABEL specifies a separator (GTK only has one |
1891 separator type) */ | 1898 separator type) */ |
1892 | 1899 |
1900 static char* separator_names[] = { | |
1901 "space", | |
1902 "no-line", | |
1903 "single-line", | |
1904 "double-line", | |
1905 "single-dashed-line", | |
1906 "double-dashed-line", | |
1907 "shadow-etched-in", | |
1908 "shadow-etched-out", | |
1909 "shadow-etched-in-dash", | |
1910 "shadow-etched-out-dash", | |
1911 "shadow-double-etched-in", | |
1912 "shadow-double-etched-out", | |
1913 "shadow-double-etched-in-dash", | |
1914 "shadow-double-etched-out-dash", | |
1915 0, | |
1916 }; | |
1917 | |
1893 static int | 1918 static int |
1894 xg_separator_p (char *label) | 1919 xg_separator_p (char *label) |
1895 { | 1920 { |
1896 if (! label) return 0; | 1921 if (! label) return 0; |
1897 else if (strlen (label) > 3 | 1922 else if (strlen (label) > 3 |
1898 && strncmp (label, "--", 2) == 0 | 1923 && strncmp (label, "--", 2) == 0 |
1899 && label[2] != '-') | 1924 && label[2] != '-') |
1900 { | 1925 { |
1901 static char* separator_names[] = { | |
1902 "space", | |
1903 "no-line", | |
1904 "single-line", | |
1905 "double-line", | |
1906 "single-dashed-line", | |
1907 "double-dashed-line", | |
1908 "shadow-etched-in", | |
1909 "shadow-etched-out", | |
1910 "shadow-etched-in-dash", | |
1911 "shadow-etched-out-dash", | |
1912 "shadow-double-etched-in", | |
1913 "shadow-double-etched-out", | |
1914 "shadow-double-etched-in-dash", | |
1915 "shadow-double-etched-out-dash", | |
1916 0, | |
1917 }; | |
1918 | |
1919 int i; | 1926 int i; |
1920 | 1927 |
1921 label += 2; | 1928 label += 2; |
1922 for (i = 0; separator_names[i]; ++i) | 1929 for (i = 0; separator_names[i]; ++i) |
1923 if (strcmp (label, separator_names[i]) == 0) | 1930 if (strcmp (label, separator_names[i]) == 0) |
2041 } | 2048 } |
2042 | 2049 |
2043 return w; | 2050 return w; |
2044 } | 2051 } |
2045 | 2052 |
2046 /* Callback called when keyboard traversal (started by menu-bar-open) ends. | 2053 /* Callback called when keyboard traversal (started by x-menu-bar-open) ends. |
2047 WMENU is the menu for which traversal has been done. DATA points to the | 2054 WMENU is the menu for which traversal has been done. DATA points to the |
2048 frame for WMENU. We must release grabs, some bad interaction between GTK | 2055 frame for WMENU. We must release grabs, some bad interaction between GTK |
2049 and Emacs makes the menus keep the grabs. */ | 2056 and Emacs makes the menus keep the grabs. */ |
2050 | 2057 |
2051 static void | 2058 static void |
3343 | 3350 |
3344 /* The key for the data we put in the GtkImage widgets. The data is | 3351 /* The key for the data we put in the GtkImage widgets. The data is |
3345 the stock name used by Emacs. We use this to see if we need to update | 3352 the stock name used by Emacs. We use this to see if we need to update |
3346 the GtkImage with a new image. */ | 3353 the GtkImage with a new image. */ |
3347 #define XG_TOOL_BAR_STOCK_NAME "emacs-tool-bar-stock-name" | 3354 #define XG_TOOL_BAR_STOCK_NAME "emacs-tool-bar-stock-name" |
3355 | |
3356 /* As above, but this is used for named theme widgets, as opposed to | |
3357 stock items. */ | |
3358 #define XG_TOOL_BAR_ICON_NAME "emacs-tool-bar-icon-name" | |
3348 | 3359 |
3349 /* Callback function invoked when a tool bar item is pressed. | 3360 /* Callback function invoked when a tool bar item is pressed. |
3350 W is the button widget in the tool bar that got pressed, | 3361 W is the button widget in the tool bar that got pressed, |
3351 CLIENT_DATA is an integer that is the index of the button in the | 3362 CLIENT_DATA is an integer that is the index of the button in the |
3352 tool bar. 0 is the first button. */ | 3363 tool bar. 0 is the first button. */ |
3633 return FALSE; | 3644 return FALSE; |
3634 } | 3645 } |
3635 | 3646 |
3636 #define PROP(IDX) AREF (f->tool_bar_items, i * TOOL_BAR_ITEM_NSLOTS + (IDX)) | 3647 #define PROP(IDX) AREF (f->tool_bar_items, i * TOOL_BAR_ITEM_NSLOTS + (IDX)) |
3637 | 3648 |
3638 /* This callback is called when a tool bar shall be redrawn. | |
3639 We need to update the images in case the image cache | |
3640 has deleted the pixmaps used in the tool bar. | |
3641 W is the GtkToolbar to be redrawn. | |
3642 EVENT is the expose event for W. | |
3643 CLIENT_DATA is pointing to the frame for this tool bar. | |
3644 | |
3645 Returns FALSE to tell GTK to keep processing this event. */ | |
3646 | |
3647 static gboolean | |
3648 xg_tool_bar_expose_callback (w, event, client_data) | |
3649 GtkWidget *w; | |
3650 GdkEventExpose *event; | |
3651 gpointer client_data; | |
3652 { | |
3653 FRAME_PTR f = (FRAME_PTR) client_data; | |
3654 SET_FRAME_GARBAGED (f); | |
3655 return FALSE; | |
3656 } | |
3657 | 3649 |
3658 /* Create a tool bar for frame F. */ | 3650 /* Create a tool bar for frame F. */ |
3659 | 3651 |
3660 static void | 3652 static void |
3661 xg_create_tool_bar (f) | 3653 xg_create_tool_bar (f) |
3693 | 3685 |
3694 g_signal_connect (G_OBJECT (x->handlebox_widget), "child-detached", | 3686 g_signal_connect (G_OBJECT (x->handlebox_widget), "child-detached", |
3695 G_CALLBACK (xg_tool_bar_detach_callback), f); | 3687 G_CALLBACK (xg_tool_bar_detach_callback), f); |
3696 g_signal_connect (G_OBJECT (x->handlebox_widget), "child-attached", | 3688 g_signal_connect (G_OBJECT (x->handlebox_widget), "child-attached", |
3697 G_CALLBACK (xg_tool_bar_attach_callback), f); | 3689 G_CALLBACK (xg_tool_bar_attach_callback), f); |
3698 g_signal_connect (G_OBJECT (x->toolbar_widget), | |
3699 "expose-event", | |
3700 G_CALLBACK (xg_tool_bar_expose_callback), | |
3701 f); | |
3702 | 3690 |
3703 gtk_widget_show_all (x->handlebox_widget); | 3691 gtk_widget_show_all (x->handlebox_widget); |
3704 | 3692 |
3705 gtk_widget_size_request (x->toolbar_widget, &req); | 3693 gtk_widget_size_request (x->toolbar_widget, &req); |
3706 FRAME_TOOLBAR_HEIGHT (f) = req.height; | 3694 FRAME_TOOLBAR_HEIGHT (f) = req.height; |
3807 struct image *img = NULL; | 3795 struct image *img = NULL; |
3808 Lisp_Object image; | 3796 Lisp_Object image; |
3809 Lisp_Object stock; | 3797 Lisp_Object stock; |
3810 GtkStockItem stock_item; | 3798 GtkStockItem stock_item; |
3811 char *stock_name = NULL; | 3799 char *stock_name = NULL; |
3800 char *icon_name = NULL; | |
3812 Lisp_Object rtl; | 3801 Lisp_Object rtl; |
3813 GtkWidget *wbutton; | 3802 GtkWidget *wbutton = NULL; |
3814 GtkWidget *weventbox; | 3803 GtkWidget *weventbox; |
3815 Lisp_Object func = intern ("x-gtk-map-stock"); | 3804 Lisp_Object func = intern ("x-gtk-map-stock"); |
3816 | 3805 |
3817 ti = gtk_toolbar_get_nth_item (GTK_TOOLBAR (x->toolbar_widget), i); | 3806 ti = gtk_toolbar_get_nth_item (GTK_TOOLBAR (x->toolbar_widget), i); |
3818 | 3807 |
3832 } | 3821 } |
3833 | 3822 |
3834 if (EQ (Qt, Ffboundp (func))) | 3823 if (EQ (Qt, Ffboundp (func))) |
3835 stock = call1 (func, file_for_image (image)); | 3824 stock = call1 (func, file_for_image (image)); |
3836 | 3825 |
3837 if (! NILP (stock) && STRINGP (stock) | 3826 if (! NILP (stock) && STRINGP (stock)) |
3838 && gtk_stock_lookup (SSDATA (stock), &stock_item)) | |
3839 { | 3827 { |
3840 stock_name = SSDATA (stock); | 3828 stock_name = SSDATA (stock); |
3841 icon_size = gtk_toolbar_get_icon_size (wtoolbar); | 3829 if (stock_name[0] == 'n' && stock_name[1] == ':') |
3830 { | |
3831 GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (wtoolbar)); | |
3832 GtkIconTheme *icon_theme = gtk_icon_theme_get_for_screen (screen); | |
3833 | |
3834 icon_name = stock_name + 2; | |
3835 stock_name = NULL; | |
3836 stock = Qnil; | |
3837 | |
3838 if (! gtk_icon_theme_has_icon (icon_theme, icon_name)) | |
3839 icon_name = NULL; | |
3840 else | |
3841 icon_size = gtk_toolbar_get_icon_size (wtoolbar); | |
3842 } | |
3843 else if (gtk_stock_lookup (SSDATA (stock), &stock_item)) | |
3844 icon_size = gtk_toolbar_get_icon_size (wtoolbar); | |
3845 else | |
3846 { | |
3847 stock = Qnil; | |
3848 stock_name = NULL; | |
3849 } | |
3842 } | 3850 } |
3843 else | 3851 |
3852 if (stock_name == NULL && icon_name == NULL) | |
3844 { | 3853 { |
3845 /* No stock image, or stock item not known. Try regular image. */ | 3854 /* No stock image, or stock item not known. Try regular image. */ |
3846 | 3855 |
3847 /* If image is a vector, choose the image according to the | 3856 /* If image is a vector, choose the image according to the |
3848 button state. */ | 3857 button state. */ |
3903 w = gtk_image_new_from_stock (stock_name, icon_size); | 3912 w = gtk_image_new_from_stock (stock_name, icon_size); |
3904 g_object_set_data_full (G_OBJECT (w), XG_TOOL_BAR_STOCK_NAME, | 3913 g_object_set_data_full (G_OBJECT (w), XG_TOOL_BAR_STOCK_NAME, |
3905 (gpointer) xstrdup (stock_name), | 3914 (gpointer) xstrdup (stock_name), |
3906 (GDestroyNotify) xfree); | 3915 (GDestroyNotify) xfree); |
3907 } | 3916 } |
3917 else if (icon_name) | |
3918 { | |
3919 w = gtk_image_new_from_icon_name (icon_name, icon_size); | |
3920 g_object_set_data_full (G_OBJECT (w), XG_TOOL_BAR_ICON_NAME, | |
3921 (gpointer) xstrdup (icon_name), | |
3922 (GDestroyNotify) xfree); | |
3923 } | |
3908 else | 3924 else |
3909 { | 3925 { |
3910 w = xg_get_image_for_pixmap (f, img, x->widget, NULL); | 3926 w = xg_get_image_for_pixmap (f, img, x->widget, NULL); |
3911 /* Save the image so we can see if an update is needed when | 3927 /* Save the image so we can see if an update is needed when |
3912 this function is called again. */ | 3928 this function is called again. */ |
3978 GtkWidget *wimage = gtk_bin_get_child (GTK_BIN (wbutton)); | 3994 GtkWidget *wimage = gtk_bin_get_child (GTK_BIN (wbutton)); |
3979 Pixmap old_img = (Pixmap)g_object_get_data (G_OBJECT (wimage), | 3995 Pixmap old_img = (Pixmap)g_object_get_data (G_OBJECT (wimage), |
3980 XG_TOOL_BAR_IMAGE_DATA); | 3996 XG_TOOL_BAR_IMAGE_DATA); |
3981 gpointer old_stock_name = g_object_get_data (G_OBJECT (wimage), | 3997 gpointer old_stock_name = g_object_get_data (G_OBJECT (wimage), |
3982 XG_TOOL_BAR_STOCK_NAME); | 3998 XG_TOOL_BAR_STOCK_NAME); |
3999 gpointer old_icon_name = g_object_get_data (G_OBJECT (wimage), | |
4000 XG_TOOL_BAR_ICON_NAME); | |
3983 if (stock_name && | 4001 if (stock_name && |
3984 (! old_stock_name || strcmp (old_stock_name, stock_name) != 0)) | 4002 (! old_stock_name || strcmp (old_stock_name, stock_name) != 0)) |
3985 { | 4003 { |
3986 gtk_image_set_from_stock (GTK_IMAGE (wimage), | 4004 gtk_image_set_from_stock (GTK_IMAGE (wimage), |
3987 stock_name, icon_size); | 4005 stock_name, icon_size); |
3988 g_object_set_data_full (G_OBJECT (wimage), XG_TOOL_BAR_STOCK_NAME, | 4006 g_object_set_data_full (G_OBJECT (wimage), XG_TOOL_BAR_STOCK_NAME, |
3989 (gpointer) xstrdup (stock_name), | 4007 (gpointer) xstrdup (stock_name), |
3990 (GDestroyNotify) xfree); | 4008 (GDestroyNotify) xfree); |
3991 g_object_set_data (G_OBJECT (wimage), XG_TOOL_BAR_IMAGE_DATA, | 4009 g_object_set_data (G_OBJECT (wimage), XG_TOOL_BAR_IMAGE_DATA, |
3992 NULL); | 4010 NULL); |
4011 g_object_set_data (G_OBJECT (wimage), XG_TOOL_BAR_ICON_NAME, NULL); | |
4012 } | |
4013 else if (icon_name && | |
4014 (! old_icon_name || strcmp (old_icon_name, icon_name) != 0)) | |
4015 { | |
4016 gtk_image_set_from_icon_name (GTK_IMAGE (wimage), | |
4017 icon_name, icon_size); | |
4018 g_object_set_data_full (G_OBJECT (wimage), XG_TOOL_BAR_ICON_NAME, | |
4019 (gpointer) xstrdup (icon_name), | |
4020 (GDestroyNotify) xfree); | |
4021 g_object_set_data (G_OBJECT (wimage), XG_TOOL_BAR_IMAGE_DATA, | |
4022 NULL); | |
4023 g_object_set_data (G_OBJECT (wimage), XG_TOOL_BAR_STOCK_NAME, | |
4024 NULL); | |
3993 } | 4025 } |
3994 else if (img && old_img != img->pixmap) | 4026 else if (img && old_img != img->pixmap) |
3995 { | 4027 { |
3996 (void) xg_get_image_for_pixmap (f, img, x->widget, wimage); | 4028 (void) xg_get_image_for_pixmap (f, img, x->widget, wimage); |
3997 g_object_set_data (G_OBJECT (wimage), XG_TOOL_BAR_IMAGE_DATA, | 4029 g_object_set_data (G_OBJECT (wimage), XG_TOOL_BAR_IMAGE_DATA, |
3998 (gpointer)img->pixmap); | 4030 (gpointer)img->pixmap); |
3999 | 4031 |
4000 g_object_set_data (G_OBJECT (wimage), XG_TOOL_BAR_STOCK_NAME, | 4032 g_object_set_data (G_OBJECT (wimage), XG_TOOL_BAR_STOCK_NAME, |
4001 NULL); | 4033 NULL); |
4034 g_object_set_data (G_OBJECT (wimage), XG_TOOL_BAR_ICON_NAME, NULL); | |
4002 } | 4035 } |
4003 | 4036 |
4004 gtk_misc_set_padding (GTK_MISC (wimage), hmargin, vmargin); | 4037 gtk_misc_set_padding (GTK_MISC (wimage), hmargin, vmargin); |
4005 | 4038 |
4006 gtk_widget_set_sensitive (wbutton, enabled_p); | 4039 gtk_widget_set_sensitive (wbutton, enabled_p); |
4069 #if HAVE_XFT | 4102 #if HAVE_XFT |
4070 /* Work around a bug with corrupted data if libXft gets unloaded. This way | 4103 /* Work around a bug with corrupted data if libXft gets unloaded. This way |
4071 we keep it permanently linked in. */ | 4104 we keep it permanently linked in. */ |
4072 XftInit (0); | 4105 XftInit (0); |
4073 #endif | 4106 #endif |
4107 | |
4108 gdpy_def = NULL; | |
4074 xg_ignore_gtk_scrollbar = 0; | 4109 xg_ignore_gtk_scrollbar = 0; |
4075 xg_detached_menus = 0; | 4110 xg_detached_menus = 0; |
4076 xg_menu_cb_list.prev = xg_menu_cb_list.next = | 4111 xg_menu_cb_list.prev = xg_menu_cb_list.next = |
4077 xg_menu_item_cb_list.prev = xg_menu_item_cb_list.next = 0; | 4112 xg_menu_item_cb_list.prev = xg_menu_item_cb_list.next = 0; |
4078 | 4113 |