patch 7.4.995

Problem:    gdk_pixbuf_new_from_inline() is deprecated.
Solution:   Generate auto/gui_gtk_gresources.c. (Kazunobu Kazunobu,
            closes #507)
This commit is contained in:
Bram Moolenaar 2015-12-29 18:55:46 +01:00
parent 4e5a31c8b3
commit 36e294c00c
24 changed files with 240 additions and 8 deletions

2
.gitignore vendored
View File

@ -3,6 +3,8 @@
src/vim
src/xxd/xxd
src/auto/if_perl.c
src/auto/gui_gtk_gresources.c
src/auto/gui_gtk_gresources.h
src/tags
# We do need src/auto/configure.

Binary file not shown.

After

Width:  |  Height:  |  Size: 439 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1021 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
pixmaps/stock_vim_shell.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 540 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 514 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 352 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 369 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 B

View File

@ -1199,10 +1199,10 @@ NONE_INSTALL = install_normal
### GTK GUI
GTK_SRC = gui.c gui_gtk.c gui_gtk_x11.c pty.c gui_gtk_f.c \
gui_beval.c
gui_beval.c $(GRESOURCE_SRC)
GTK_OBJ = objects/gui.o objects/gui_gtk.o objects/gui_gtk_x11.o \
objects/pty.o objects/gui_gtk_f.o \
objects/gui_beval.o
objects/gui_beval.o $(GRESOURCE_OBJ)
GTK_DEFS = -DFEAT_GUI_GTK $(NARROW_PROTO)
GTK_IPATH = $(GUI_INC_LOC)
GTK_LIBS_DIR = $(GUI_LIB_LOC)
@ -1527,7 +1527,8 @@ TAGS_SRC = *.c *.cpp if_perl.xs
EXTRA_SRC = hangulin.c if_lua.c if_mzsch.c auto/if_perl.c if_perlsfio.c \
if_python.c if_python3.c if_tcl.c if_ruby.c if_sniff.c \
gui_beval.c workshop.c wsdebug.c integration.c netbeans.c
gui_beval.c workshop.c wsdebug.c integration.c netbeans.c \
$(GRESOURCE_SRC)
# Unittest files
MEMFILE_TEST_SRC = memfile_test.c
@ -1869,6 +1870,9 @@ os_vms.pro: os_vms.c
if_perl.pro: auto/if_perl.c
$(CPROTO) -DFEAT_GUI auto/if_perl.c | sed "/_VI/d" > proto/$@
gui_gtk_gresources.pro: auto/gui_gtk_gresources.c
$(CPROTO) -DFEAT_GUI $< > proto/$@
echo "/* vim: set ft=c : */" >> proto/$@
notags:
-rm -f tags
@ -2441,7 +2445,7 @@ uninstall_runtime:
# We support common typing mistakes for Juergen! :-)
clean celan: testclean
-rm -f *.o objects/* core $(VIMTARGET).core $(VIMTARGET) vim xxd/*.o
-rm -f $(TOOLS) auto/osdef.h auto/pathdef.c auto/if_perl.c
-rm -f $(TOOLS) auto/osdef.h auto/pathdef.c auto/if_perl.c auto/gui_gtk_gresources.c auto/gui_gtk_gresources.h
-rm -f conftest* *~ auto/link.sed
-rm -f $(UNITTEST_TARGETS)
-rm -f runtime pixmaps
@ -2578,6 +2582,11 @@ auto/pathdef.c: Makefile auto/config.mk
-@echo '";' >> $@
-@sh $(srcdir)/pathdef.sh
auto/gui_gtk_gresources.c: gui_gtk_gresources.xml
$(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=../pixmaps --generate --c-name=gui_gtk --manual-register $<
auto/gui_gtk_gresources.h: gui_gtk_gresources.xml
$(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=../pixmaps --generate --c-name=gui_gtk --manual-register $<
# All the object files are put in the "objects" directory. Since not all make
# commands understand putting object files in another directory, it must be
# specified for each file separately.
@ -2663,6 +2672,9 @@ objects/gui_gtk.o: gui_gtk.c
objects/gui_gtk_f.o: gui_gtk_f.c
$(CCC) -o $@ gui_gtk_f.c
objects/gui_gtk_gresources.o: auto/gui_gtk_gresources.c
$(CCC) $(PERL_CFLAGS) -o $@ auto/gui_gtk_gresources.c
objects/gui_gtk_x11.o: gui_gtk_x11.c
$(CCC) -o $@ gui_gtk_x11.c
@ -3145,6 +3157,16 @@ objects/gui_gtk_f.o: gui_gtk_f.c vim.h auto/config.h feature.h os_unix.h \
auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
globals.h farsi.h arabic.h gui_gtk_f.h
objects/gui_gtk_gresources.o: auto/gui_gtk_gresources.c gui_gtk_gresources.xml \
../pixmaps/stock_vim_build_tags.png ../pixmaps/stock_vim_find_help.png \
../pixmaps/stock_vim_save_all.png ../pixmaps/stock_vim_session_load.png \
../pixmaps/stock_vim_session_new.png ../pixmaps/stock_vim_session_save.png \
../pixmaps/stock_vim_shell.png ../pixmaps/stock_vim_window_maximize.png \
../pixmaps/stock_vim_window_maximize_width.png \
../pixmaps/stock_vim_window_minimize.png \
../pixmaps/stock_vim_window_minimize_width.png \
../pixmaps/stock_vim_window_split.png \
../pixmaps/stock_vim_window_split_vertical.png
objects/gui_motif.o: gui_motif.c vim.h auto/config.h feature.h os_unix.h \
auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
@ -3197,7 +3219,7 @@ objects/gui_gtk_x11.o: gui_gtk_x11.c vim.h auto/config.h feature.h os_unix.h \
auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
globals.h farsi.h arabic.h gui_gtk_f.h ../runtime/vim32x32.xpm \
../runtime/vim16x16.xpm ../runtime/vim48x48.xpm
../runtime/vim16x16.xpm ../runtime/vim48x48.xpm $(GRESOURCE_HDR)
objects/gui_x11.o: gui_x11.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \

84
src/auto/configure vendored
View File

@ -636,6 +636,10 @@ GUI_LIB_LOC
GUI_INC_LOC
NARROW_PROTO
MOTIF_LIBNAME
GRESOURCE_OBJ
GRESOURCE_SRC
GRESOURCE_HDR
GLIB_COMPILE_RESOURCES
GNOME_INCLUDEDIR
GNOME_LIBDIR
GNOME_LIBS
@ -8907,6 +8911,86 @@ $as_echo "not found" >&6; }
fi
fi
if test "x$GUITYPE" = "xGTK"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking version of Gdk-Pixbuf" >&5
$as_echo_n "checking version of Gdk-Pixbuf... " >&6; }
gdk_pixbuf_version=`$PKG_CONFIG --modversion gdk-pixbuf-2.0`
if test "x$gdk_pixbuf_version" != x ; then
gdk_pixbuf_version_minor=`echo $gdk_pixbuf_version | \
sed -e 's/[0-9][0-9]*\.\([0-9][0-9]*\)\.[0-9][0-9]*/\1/'`
if test "x$gdk_pixbuf_version_minor" != x -a \
$gdk_pixbuf_version_minor -ge 32 ; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: OK." >&5
$as_echo "OK." >&6; }
# Extract the first word of "glib-compile-resources", so it can be a program name with args.
set dummy glib-compile-resources; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_path_GLIB_COMPILE_RESOURCES+:} false; then :
$as_echo_n "(cached) " >&6
else
case $GLIB_COMPILE_RESOURCES in
[\\/]* | ?:[\\/]*)
ac_cv_path_GLIB_COMPILE_RESOURCES="$GLIB_COMPILE_RESOURCES" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_path_GLIB_COMPILE_RESOURCES="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
test -z "$ac_cv_path_GLIB_COMPILE_RESOURCES" && ac_cv_path_GLIB_COMPILE_RESOURCES="no"
;;
esac
fi
GLIB_COMPILE_RESOURCES=$ac_cv_path_GLIB_COMPILE_RESOURCES
if test -n "$GLIB_COMPILE_RESOURCES"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $GLIB_COMPILE_RESOURCES" >&5
$as_echo "$GLIB_COMPILE_RESOURCES" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking glib-compile-resources" >&5
$as_echo_n "checking glib-compile-resources... " >&6; }
if test "x$GLIB_COMPILE_RESOURCES" = xno ; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: cannot be found in PATH." >&5
$as_echo "cannot be found in PATH." >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: usable." >&5
$as_echo "usable." >&6; }
$as_echo "#define USE_GRESOURCE 1" >>confdefs.h
GRESOURCE_HDR="auto/gui_gtk_gresources.h"
GRESOURCE_SRC="auto/gui_gtk_gresources.c"
GRESOURCE_OBJ="objects/gui_gtk_gresources.o"
fi
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: not usable." >&5
$as_echo "not usable." >&6; }
fi
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: cannot obtain from pkg_config." >&5
$as_echo "cannot obtain from pkg_config." >&6; }
fi
fi
if test -z "$SKIP_MOTIF"; then
gui_XXX="/usr/XXX/Motif* /usr/Motif*/XXX /usr/XXX /usr/shlib /usr/X11*/XXX /usr/XXX/X11* /usr/dt/XXX /local/Motif*/XXX /local/XXX/Motif* /usr/local/Motif*/XXX /usr/local/XXX/Motif* /usr/local/XXX /usr/local/X11*/XXX /usr/local/LessTif/Motif*/XXX $MOTIFHOME/XXX"

View File

@ -452,3 +452,6 @@
/* Define if Xutf8SetWMProperties() is in an X library. */
#undef HAVE_XUTF8SETWMPROPERTIES
/* Define if GResource is used to load icons */
#undef USE_GRESOURCE

View File

@ -158,6 +158,11 @@ GUI_X_LIBS = @GUI_X_LIBS@
MOTIF_LIBNAME = @MOTIF_LIBNAME@
GTK_LIBNAME = @GTK_LIBNAME@
GLIB_COMPILE_RESOURCES = @GLIB_COMPILE_RESOURCES@
GRESOURCE_HDR = @GRESOURCE_HDR@
GRESOURCE_SRC = @GRESOURCE_SRC@
GRESOURCE_OBJ = @GRESOURCE_OBJ@
### Any OS dependent extra source and object file
OS_EXTRA_SRC = @OS_EXTRA_SRC@
OS_EXTRA_OBJ = @OS_EXTRA_OBJ@

View File

@ -2500,6 +2500,40 @@ if test -z "$SKIP_GTK2"; then
fi
fi
dnl Check the version of Gdk-Pixbuf. If the version is 2.32 or later and
dnl glib-compile-resources is found in PATH, use GResource.
if test "x$GUITYPE" = "xGTK"; then
AC_MSG_CHECKING([version of Gdk-Pixbuf])
gdk_pixbuf_version=`$PKG_CONFIG --modversion gdk-pixbuf-2.0`
if test "x$gdk_pixbuf_version" != x ; then
gdk_pixbuf_version_minor=`echo $gdk_pixbuf_version | \
sed -e 's/[[0-9]][[0-9]]*\.\([[0-9]][[0-9]]*\)\.[[0-9]][[0-9]]*/\1/'`
if test "x$gdk_pixbuf_version_minor" != x -a \
$gdk_pixbuf_version_minor -ge 32 ; then
AC_MSG_RESULT([OK.])
AC_PATH_PROG(GLIB_COMPILE_RESOURCES,[glib-compile-resources],no)
AC_MSG_CHECKING([glib-compile-resources])
if test "x$GLIB_COMPILE_RESOURCES" = xno ; then
AC_MSG_RESULT([cannot be found in PATH.])
else
AC_MSG_RESULT([usable.])
AC_DEFINE(USE_GRESOURCE)
GRESOURCE_HDR="auto/gui_gtk_gresources.h"
GRESOURCE_SRC="auto/gui_gtk_gresources.c"
GRESOURCE_OBJ="objects/gui_gtk_gresources.o"
fi
else
AC_MSG_RESULT([not usable.])
fi
else
AC_MSG_RESULT([cannot obtain from pkg_config.])
fi
fi
AC_SUBST(GLIB_COMPILE_RESOURCES)
AC_SUBST(GRESOURCE_HDR)
AC_SUBST(GRESOURCE_SRC)
AC_SUBST(GRESOURCE_OBJ)
dnl Check for Motif include files location.
dnl The LAST one found is used, this makes the highest version to be used,
dnl e.g. when Motif1.2 and Motif2.0 are both present.

View File

@ -140,6 +140,31 @@ static const char * const menu_stock_ids[] =
/* 31 */ GTK_STOCK_QUIT
};
#ifdef USE_GRESOURCE
typedef struct IconNames {
const char *icon_name;
const char *file_name;
} IconNames;
static IconNames stock_vim_icons[] = {
{ "vim-build-tags", "stock_vim_build_tags.png" },
{ "vim-find-help", "stock_vim_find_help.png" },
{ "vim-save-all", "stock_vim_save_all.png" },
{ "vim-session-load", "stock_vim_session_load.png" },
{ "vim-session-new", "stock_vim_session_new.png" },
{ "vim-session-save", "stock_vim_session_save.png" },
{ "vim-shell", "stock_vim_shell.png" },
{ "vim-window-maximize", "stock_vim_window_maximize.png" },
{ "vim-window-maximize-width", "stock_vim_window_maximize_width.png" },
{ "vim-window-minimize", "stock_vim_window_minimize.png" },
{ "vim-window-minimize-width", "stock_vim_window_minimize_width.png" },
{ "vim-window-split", "stock_vim_window_split.png" },
{ "vim-window-split-vertical", "stock_vim_window_split_vertical.png" },
{ NULL, NULL }
};
#endif
#ifndef USE_GRESOURCE
static void
add_stock_icon(GtkIconFactory *factory,
const char *stock_id,
@ -157,6 +182,7 @@ add_stock_icon(GtkIconFactory *factory,
gtk_icon_set_unref(icon_set);
g_object_unref(pixbuf);
}
#endif
static int
lookup_menu_iconfile(char_u *iconfile, char_u *dest)
@ -262,11 +288,12 @@ toolbar_button_focus_in_event(GtkWidget *widget UNUSED,
void
gui_gtk_register_stock_icons(void)
{
# include "../pixmaps/stock_icons.h"
#ifndef USE_GRESOURCE
# include "../pixmaps/stock_icons.h"
GtkIconFactory *factory;
factory = gtk_icon_factory_new();
# define ADD_ICON(Name, Data) add_stock_icon(factory, Name, Data, (int)sizeof(Data))
# define ADD_ICON(Name, Data) add_stock_icon(factory, Name, Data, (int)sizeof(Data))
ADD_ICON("vim-build-tags", stock_vim_build_tags);
ADD_ICON("vim-find-help", stock_vim_find_help);
@ -282,7 +309,28 @@ gui_gtk_register_stock_icons(void)
ADD_ICON("vim-window-split", stock_vim_window_split);
ADD_ICON("vim-window-split-vertical", stock_vim_window_split_vertical);
# undef ADD_ICON
# undef ADD_ICON
#else
GtkIconFactory * const factory = gtk_icon_factory_new();
const char * const path_prefix = "/org/vim/gui/icon";
IconNames *names;
for (names = stock_vim_icons; names->icon_name != NULL; names++)
{
char path[MAXPATHL];
GdkPixbuf *pixbuf;
vim_snprintf(path, MAXPATHL, "%s/%s", path_prefix, names->file_name);
pixbuf = gdk_pixbuf_new_from_resource(path, NULL);
if (pixbuf != NULL)
{
GtkIconSet *icon_set = gtk_icon_set_new_from_pixbuf(pixbuf);
gtk_icon_factory_add(factory, names->icon_name, icon_set);
gtk_icon_set_unref(icon_set);
g_object_unref(pixbuf);
}
}
#endif
gtk_icon_factory_add_default(factory);
g_object_unref(factory);
}

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/vim/gui/icon">
<file>stock_vim_build_tags.png</file>
<file>stock_vim_find_help.png</file>
<file>stock_vim_save_all.png</file>
<file>stock_vim_session_load.png</file>
<file>stock_vim_session_new.png</file>
<file>stock_vim_session_save.png</file>
<file>stock_vim_shell.png</file>
<file>stock_vim_window_maximize.png</file>
<file>stock_vim_window_maximize_width.png</file>
<file>stock_vim_window_minimize.png</file>
<file>stock_vim_window_minimize_width.png</file>
<file>stock_vim_window_split.png</file>
<file>stock_vim_window_split_vertical.png</file>
</gresource>
</gresources>

View File

@ -22,6 +22,9 @@
*/
#include "vim.h"
#ifdef USE_GRESOURCE
#include "auto/gui_gtk_gresources.h"
#endif
#ifdef FEAT_GUI_GNOME
/* Gnome redefines _() and N_(). Grrr... */
@ -1434,6 +1437,9 @@ gui_mch_early_init_check(void)
EMSG(_((char *)e_opendisp));
return FAIL;
}
#ifdef USE_GRESOURCE
gui_gtk_register_resource();
#endif
return OK;
}
@ -3620,6 +3626,9 @@ mainwin_destroy_cb(GtkObject *object UNUSED, gpointer data UNUSED)
IOSIZE - 1);
preserve_exit();
}
#ifdef USE_GRESOURCE
gui_gtk_unregister_resource();
#endif
}

View File

@ -0,0 +1,5 @@
/* auto/gui_gtk_gresources.c */
GResource *gui_gtk_get_resource __ARGS((void));
void gui_gtk_register_resource __ARGS((void));
void gui_gtk_unregister_resource __ARGS((void));
/* vim: set ft=c : */

View File

@ -741,6 +741,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
995,
/**/
994,
/**/