ui.backend.gtk: load icon data directly into factor.image when deploying, no io is needed
parent
ab29ed3892
commit
8c61b874b7
|
@ -1,7 +1,8 @@
|
||||||
! Copyright (C) 2009 Anton Gorenko.
|
! Copyright (C) 2009 Anton Gorenko.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: alien alien.libraries combinators kernel system
|
USING: alien alien.data alien.libraries alien.syntax
|
||||||
gobject-introspection gio.ffi glib.ffi gmodule.ffi gobject.ffi ;
|
combinators gio.ffi glib.ffi gmodule.ffi gobject-introspection
|
||||||
|
gobject.ffi kernel libc sequences system ;
|
||||||
EXCLUDE: alien.c-types => pointer ;
|
EXCLUDE: alien.c-types => pointer ;
|
||||||
IN: gdk.pixbuf.ffi
|
IN: gdk.pixbuf.ffi
|
||||||
|
|
||||||
|
@ -15,3 +16,11 @@ IN: gdk.pixbuf.ffi
|
||||||
|
|
||||||
GIR: vocab:gdk/pixbuf/GdkPixbuf-2.0.gir
|
GIR: vocab:gdk/pixbuf/GdkPixbuf-2.0.gir
|
||||||
|
|
||||||
|
: data>GInputStream ( data -- GInputStream )
|
||||||
|
[ malloc-byte-array &free ] [ length ] bi
|
||||||
|
f g_memory_input_stream_new_from_data ;
|
||||||
|
|
||||||
|
: GInputStream>GdkPixbuf ( GInputStream -- GdkPixbuf )
|
||||||
|
f { { pointer: GError initial: f } }
|
||||||
|
[ gdk_pixbuf_new_from_stream ] with-out-parameters
|
||||||
|
handle-GError ;
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
! Copyright (C) 2010 Philipp Brüschweiler.
|
! Copyright (C) 2010 Philipp Brüschweiler.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors alien.c-types alien.data alien.strings
|
USING: accessors alien.c-types alien.data arrays combinators
|
||||||
alien.syntax arrays classes.struct combinators destructors
|
destructors gdk.pixbuf.ffi gobject.ffi grouping images
|
||||||
gdk.pixbuf.ffi gio.ffi glib.ffi gobject.ffi grouping images
|
images.loader io kernel locals math sequences
|
||||||
images.loader io io.encodings.utf8
|
specialized-arrays ;
|
||||||
kernel libc locals math sequences specialized-arrays ;
|
|
||||||
IN: images.gtk
|
IN: images.gtk
|
||||||
SPECIALIZED-ARRAY: uchar
|
SPECIALIZED-ARRAY: uchar
|
||||||
|
|
||||||
|
@ -20,15 +19,6 @@ SINGLETON: gtk-image
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
|
||||||
: data>GInputStream ( data -- GInputStream )
|
|
||||||
[ malloc-byte-array &free ] [ length ] bi
|
|
||||||
f g_memory_input_stream_new_from_data &g_object_unref ;
|
|
||||||
|
|
||||||
: GInputStream>GdkPixbuf ( GInputStream -- GdkPixbuf )
|
|
||||||
f { { pointer: GError initial: f } }
|
|
||||||
[ gdk_pixbuf_new_from_stream ] with-out-parameters
|
|
||||||
handle-GError &g_object_unref ;
|
|
||||||
|
|
||||||
: image-data ( GdkPixbuf -- data )
|
: image-data ( GdkPixbuf -- data )
|
||||||
{
|
{
|
||||||
[ gdk_pixbuf_get_pixels ]
|
[ gdk_pixbuf_get_pixels ]
|
||||||
|
@ -72,6 +62,7 @@ PRIVATE>
|
||||||
|
|
||||||
M: gtk-image stream>image
|
M: gtk-image stream>image
|
||||||
drop [
|
drop [
|
||||||
stream-contents data>GInputStream
|
stream-contents data>GInputStream &g_object_unref
|
||||||
GInputStream>GdkPixbuf GdkPixbuf>image
|
GInputStream>GdkPixbuf &g_object_unref
|
||||||
|
GdkPixbuf>image
|
||||||
] with-destructors ;
|
] with-destructors ;
|
||||||
|
|
|
@ -93,6 +93,13 @@ IN: tools.deploy.shaker
|
||||||
run-file
|
run-file
|
||||||
] when ;
|
] when ;
|
||||||
|
|
||||||
|
: strip-gtk-icon ( -- )
|
||||||
|
"ui.backend.gtk" vocab [
|
||||||
|
"Stripping GTK icon loading code" show
|
||||||
|
"vocab:tools/deploy/shaker/strip-gtk-icon.factor"
|
||||||
|
run-file
|
||||||
|
] when ;
|
||||||
|
|
||||||
: strip-specialized-arrays ( -- )
|
: strip-specialized-arrays ( -- )
|
||||||
strip-dictionary? "specialized-arrays" vocab and [
|
strip-dictionary? "specialized-arrays" vocab and [
|
||||||
"Stripping specialized arrays" show
|
"Stripping specialized arrays" show
|
||||||
|
@ -534,6 +541,7 @@ SYMBOL: deploy-vocab
|
||||||
strip-destructors
|
strip-destructors
|
||||||
strip-call
|
strip-call
|
||||||
strip-cocoa
|
strip-cocoa
|
||||||
|
strip-gtk-icon
|
||||||
strip-debugger
|
strip-debugger
|
||||||
strip-ui-error-hook
|
strip-ui-error-hook
|
||||||
strip-specialized-arrays
|
strip-specialized-arrays
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
! Copyright (C) 2010 Philipp Brüschweiler
|
||||||
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
|
USING: kernel tools.deploy.shaker literals namespaces
|
||||||
|
vocabs.loader io.pathnames io.files io.encodings.binary ;
|
||||||
|
IN: ui.backend.gtk
|
||||||
|
|
||||||
|
CONSTANT: get-icon-data
|
||||||
|
$[
|
||||||
|
deploy-vocab get
|
||||||
|
dup vocab-dir "icon.png" append-path vocab-append-path
|
||||||
|
[ exists? ] keep "resource:misc/icons/Factor_48x48.png" ?
|
||||||
|
binary file-contents
|
||||||
|
]
|
|
@ -1,22 +1,12 @@
|
||||||
! Copyright (C) 2008 James Cash
|
! Copyright (C) 2008 James Cash
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: io io.backend io.directories io.files io.files.info.unix
|
USING: io io.backend io.directories io.files.info.unix kernel
|
||||||
io.pathnames kernel namespaces sequences system
|
namespaces sequences system tools.deploy.backend
|
||||||
tools.deploy.backend tools.deploy.config
|
tools.deploy.config tools.deploy.config.editor ;
|
||||||
tools.deploy.config.editor vocabs.loader vocabs.metadata ;
|
|
||||||
IN: tools.deploy.unix
|
IN: tools.deploy.unix
|
||||||
|
|
||||||
: used-icon ( vocab -- ico )
|
|
||||||
dup vocab-dir "icon.png" append-path vocab-append-path
|
|
||||||
[ exists? ] keep "vocab:ui/backend/gtk/icon.png" ? ;
|
|
||||||
|
|
||||||
: copy-icon ( vocab bundle-name -- )
|
|
||||||
[ used-icon ]
|
|
||||||
[ "ui/backend/gtk/icon.png" append-path ] bi*
|
|
||||||
copy-file ;
|
|
||||||
|
|
||||||
: create-app-dir ( vocab bundle-name -- vm )
|
: create-app-dir ( vocab bundle-name -- vm )
|
||||||
[ copy-vm ] [ copy-icon ] 2bi
|
copy-vm
|
||||||
dup OCT: 755 set-file-permissions ;
|
dup OCT: 755 set-file-permissions ;
|
||||||
|
|
||||||
: bundle-name ( -- str )
|
: bundle-name ( -- str )
|
||||||
|
|
|
@ -1,16 +1,17 @@
|
||||||
! Copyright (C) 2010 Anton Gorenko, Philipp Brüschweiler.
|
! Copyright (C) 2010 Anton Gorenko, Philipp Brüschweiler.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors alien.accessors alien.c-types alien.data
|
USING: accessors alien.accessors alien.c-types alien.data
|
||||||
alien.strings alien.syntax arrays assocs classes.struct
|
alien.strings arrays assocs classes.struct command-line
|
||||||
command-line destructors gdk.ffi gdk.gl.ffi glib.ffi
|
destructors gdk.ffi gdk.gl.ffi gdk.pixbuf.ffi glib.ffi
|
||||||
gobject.ffi gtk.ffi gtk.gl.ffi io.backend
|
gobject.ffi gtk.ffi gtk.gl.ffi io.backend
|
||||||
io.backend.unix.multiplexers io.encodings.utf8 io.thread kernel
|
io.backend.unix.multiplexers io.encodings.binary
|
||||||
libc literals locals math math.bitwise math.order math.vectors
|
io.encodings.utf8 io.files io.thread kernel libc literals
|
||||||
namespaces sequences strings system threads ui ui.backend
|
locals math math.bitwise math.order math.vectors namespaces
|
||||||
ui.clipboards ui.commands ui.event-loop ui.gadgets
|
sequences strings system threads ui ui.backend ui.clipboards
|
||||||
ui.gadgets.editors ui.gadgets.menus ui.gadgets.private
|
ui.commands ui.event-loop ui.gadgets ui.gadgets.editors
|
||||||
ui.gadgets.worlds ui.gestures ui.pixel-formats
|
ui.gadgets.menus ui.gadgets.private ui.gadgets.worlds
|
||||||
ui.pixel-formats.private ui.private ;
|
ui.gestures ui.pixel-formats ui.pixel-formats.private
|
||||||
|
ui.private ;
|
||||||
IN: ui.backend.gtk
|
IN: ui.backend.gtk
|
||||||
|
|
||||||
SINGLETON: gtk-ui-backend
|
SINGLETON: gtk-ui-backend
|
||||||
|
@ -268,15 +269,16 @@ SYMBOL: next-timeout
|
||||||
f g_source_attach drop
|
f g_source_attach drop
|
||||||
nano-count next-timeout set-global ;
|
nano-count next-timeout set-global ;
|
||||||
|
|
||||||
|
! This word gets replaced when deploying. See 'Vocabulary icons'
|
||||||
|
! in the docs and tools.deploy.shaker.gtk-icon
|
||||||
|
: get-icon-data ( -- byte-array )
|
||||||
|
"resource:misc/icons/Factor_48x48.png" binary file-contents ;
|
||||||
|
|
||||||
: load-icon ( -- )
|
: load-icon ( -- )
|
||||||
! This file is not in a resource.txt because it can be
|
get-icon-data [
|
||||||
! overwritten when deploying. See 'Vocabulary icons'
|
data>GInputStream &g_object_unref
|
||||||
! in the docs.
|
GInputStream>GdkPixbuf gtk_window_set_default_icon
|
||||||
"vocab:ui/backend/gtk/icon.png"
|
] with-destructors ;
|
||||||
normalize-path utf8 string>alien
|
|
||||||
{ { pointer: GError initial: f } }
|
|
||||||
[ gtk_window_set_default_icon_from_file ] with-out-parameters
|
|
||||||
handle-GError drop ;
|
|
||||||
|
|
||||||
M: gtk-ui-backend (with-ui)
|
M: gtk-ui-backend (with-ui)
|
||||||
[
|
[
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 7.1 KiB |
Loading…
Reference in New Issue