ui.backend.gtk: use a global variable to store the icon data
It's easier than the previous code that replaced the get-icon-data word during deployment. Also GTK support for icon.ico icons.char-rename
parent
2c8b2d9bf5
commit
ee80cb0752
|
@ -1,13 +1,6 @@
|
|||
! 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 ;
|
||||
USING: namespaces tools.deploy.shaker ;
|
||||
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_128x128.png" ?
|
||||
binary file-contents
|
||||
]
|
||||
deploy-vocab get vocab-icon-data icon-data set-global
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
USING: alien gdk.ffi gtk.ffi help.markup help.syntax kernel ;
|
||||
USING: alien byte-arrays gdk.ffi gtk.ffi help.markup help.syntax
|
||||
kernel ;
|
||||
IN: ui.backend.gtk
|
||||
|
||||
HELP: configure-im
|
||||
|
@ -6,6 +7,9 @@ HELP: configure-im
|
|||
{ $description "Configures the input methods of the window. Must only be run after the window has been realized." }
|
||||
{ $see-also gtk_widget_realize } ;
|
||||
|
||||
HELP: icon-data
|
||||
{ $var-description "Contains a " { $link byte-array } " or " { $link f } " which is the data for the icon to be used for gtk windows. The variable is updated to contain a vocab-specific icon when deploying. See " { $link "vocabs.icons" } " and 'tools.deploy.shaker.strip-gtk-icon'." } ;
|
||||
|
||||
HELP: on-configure
|
||||
{ $values
|
||||
{ "win" alien }
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
USING: alien.syntax classes.struct gdk.ffi kernel system tools.test
|
||||
ui.backend.gtk ui.gestures ;
|
||||
USING: alien.syntax classes.struct gdk.ffi kernel sequences system
|
||||
tools.test ui.backend.gtk ui.gestures ;
|
||||
IN: ui.backend.gtk.tests
|
||||
|
||||
: gdk-key-release-event ( -- event )
|
||||
|
@ -59,3 +59,7 @@ os linux? [
|
|||
gdk-space-key-press-event key-event>gesture
|
||||
] unit-test
|
||||
] when
|
||||
|
||||
{ 9854 } [
|
||||
"gpu.demos.bunny" vocab-icon-data length
|
||||
] unit-test
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
! Copyright (C) 2010, 2011 Anton Gorenko, Philipp Bruschweiler.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: accessors alien.accessors alien.c-types alien.data
|
||||
alien.strings arrays assocs classes.struct combinators
|
||||
continuations destructors environment gdk.ffi gdk.gl.ffi
|
||||
gdk.pixbuf.ffi glib.ffi gobject-introspection.standard-types
|
||||
gobject.ffi gtk.ffi gtk.gl.ffi io.encodings.binary
|
||||
io.encodings.utf8 io.files kernel libc literals locals math
|
||||
math.bitwise math.vectors namespaces sequences strings system
|
||||
threads ui ui.backend ui.backend.gtk.input-methods
|
||||
ui.backend.gtk.io ui.clipboards ui.event-loop ui.gadgets
|
||||
ui.gadgets.private ui.gadgets.worlds ui.gestures
|
||||
ui.pixel-formats ui.pixel-formats.private ui.private
|
||||
alien.strings arrays assocs classes.struct combinators continuations
|
||||
destructors environment gdk.ffi gdk.gl.ffi gdk.pixbuf.ffi glib.ffi
|
||||
gobject-introspection.standard-types gobject.ffi gtk.ffi gtk.gl.ffi
|
||||
io.encodings.binary io.encodings.utf8 io.files io.pathnames kernel
|
||||
libc literals locals math math.bitwise math.vectors namespaces
|
||||
sequences strings system threads ui ui.backend
|
||||
ui.backend.gtk.input-methods ui.backend.gtk.io ui.clipboards
|
||||
ui.event-loop ui.gadgets ui.gadgets.private ui.gadgets.worlds
|
||||
ui.gestures ui.pixel-formats ui.pixel-formats.private ui.private
|
||||
vocabs.loader ;
|
||||
IN: ui.backend.gtk
|
||||
|
||||
|
@ -215,15 +214,25 @@ CONSTANT: action-key-codes
|
|||
: on-focus-out ( win event user-data -- ? )
|
||||
2drop window unfocus-world t ;
|
||||
|
||||
! This word gets replaced when deploying. See 'Vocabulary icons'
|
||||
! in the docs and tools.deploy.shaker.gtk-icon
|
||||
: get-icon-data ( -- byte-array/f )
|
||||
CONSTANT: default-icon-path "resource:misc/icons/Factor_128x128.png"
|
||||
|
||||
: default-icon-data ( -- byte-array/f )
|
||||
[
|
||||
"resource:misc/icons/Factor_128x128.png" binary file-contents
|
||||
default-icon-path binary file-contents
|
||||
] [ drop f ] recover ;
|
||||
|
||||
SYMBOL: icon-data
|
||||
|
||||
icon-data [ default-icon-data ] initialize
|
||||
|
||||
: vocab-icon-data ( vocab-name -- byte-array )
|
||||
dup vocab-dir { "icon.png" "icon.ico" } [
|
||||
append-path vocab-append-path
|
||||
] 2with map default-icon-path suffix
|
||||
[ exists? ] find nip binary file-contents ;
|
||||
|
||||
: load-icon ( -- )
|
||||
get-icon-data [
|
||||
icon-data get [
|
||||
[
|
||||
data>GInputStream &g_object_unref
|
||||
GInputStream>GdkPixbuf gtk_window_set_default_icon
|
||||
|
|
|
@ -30,10 +30,11 @@ ARTICLE: "vocabs.roots" "Vocabulary roots"
|
|||
ARTICLE: "vocabs.icons" "Vocabulary icons"
|
||||
"An icon file representing the vocabulary can be provided for use by " { $link "tools.deploy" } ". If any of the following files exist inside the vocabulary directory, they will be used as icons when the application is deployed."
|
||||
{ $list
|
||||
{ { $snippet "icon.ico" } " on Windows" }
|
||||
{ { $snippet "icon.ico" } " on Windows and Linux" }
|
||||
{ { $snippet "icon.icns" } " on MacOS X" }
|
||||
{ { $snippet "icon.png" } " on Linux and *BSD" }
|
||||
} ;
|
||||
{ { $snippet "icon.png" } " on Linux" }
|
||||
}
|
||||
"The icon file will be embedded in the vocab's image file." ;
|
||||
|
||||
ARTICLE: "vocabs.loader" "Vocabulary loader"
|
||||
"The " { $link POSTPONE: USE: } " and " { $link POSTPONE: USING: } " words load vocabularies using the vocabulary loader. The vocabulary loader is implemented in the " { $vocab-link "vocabs.loader" } " vocabulary."
|
||||
|
|
Loading…
Reference in New Issue