]> gitweb.factorcode.org Git - factor.git/commitdiff
ui.backend.gtk: load icon data directly into factor.image when deploying, no io is...
authorPhilipp Brüschweiler <blei42@gmail.com>
Mon, 26 Jul 2010 19:11:53 +0000 (21:11 +0200)
committerPhilipp Brüschweiler <blei42@gmail.com>
Mon, 26 Jul 2010 19:11:53 +0000 (21:11 +0200)
basis/gdk/pixbuf/ffi/ffi.factor
basis/images/gtk/gtk.factor
basis/tools/deploy/shaker/shaker.factor
basis/tools/deploy/shaker/strip-gtk-icon.factor [new file with mode: 0644]
basis/tools/deploy/unix/unix.factor
basis/ui/backend/gtk/gtk.factor
basis/ui/backend/gtk/icon.png [deleted file]

index a87ca77c3b108bb7da57ec3c31d21e087bfa9695..38959c9004f31542a38c2823272b016c9957927f 100644 (file)
@@ -1,7 +1,8 @@
 ! Copyright (C) 2009 Anton Gorenko.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien alien.libraries combinators kernel system
-gobject-introspection gio.ffi glib.ffi gmodule.ffi gobject.ffi ;
+USING: alien alien.data alien.libraries alien.syntax
+combinators gio.ffi glib.ffi gmodule.ffi gobject-introspection
+gobject.ffi kernel libc sequences system ;
 EXCLUDE: alien.c-types => pointer ;
 IN: gdk.pixbuf.ffi
 
@@ -15,3 +16,11 @@ IN: gdk.pixbuf.ffi
 
 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 ;
index e08ac996addd134ede3216db4cbd23ee8edcd18f..4957a4d216d2664897d43f5f854fac3464dc176b 100644 (file)
@@ -1,10 +1,9 @@
 ! Copyright (C) 2010 Philipp Brüschweiler.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alien.c-types alien.data alien.strings
-alien.syntax arrays classes.struct combinators destructors
-gdk.pixbuf.ffi gio.ffi glib.ffi gobject.ffi grouping images
-images.loader io io.encodings.utf8
-kernel libc locals math sequences specialized-arrays ;
+USING: accessors alien.c-types alien.data arrays combinators
+destructors gdk.pixbuf.ffi gobject.ffi grouping images
+images.loader io kernel locals math sequences
+specialized-arrays ;
 IN: images.gtk
 SPECIALIZED-ARRAY: uchar
 
@@ -20,15 +19,6 @@ SINGLETON: gtk-image
 
 <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 )
     {
         [ gdk_pixbuf_get_pixels ]
@@ -72,6 +62,7 @@ PRIVATE>
 
 M: gtk-image stream>image
     drop [
-        stream-contents data>GInputStream
-        GInputStream>GdkPixbuf GdkPixbuf>image
+        stream-contents data>GInputStream &g_object_unref
+        GInputStream>GdkPixbuf &g_object_unref
+        GdkPixbuf>image
     ] with-destructors ;
index 941b3e07f2ea1dde698123b0be5f36e84072e8b9..e74bfda3ce49672844bb057ba48beef484e28950 100755 (executable)
@@ -93,6 +93,13 @@ IN: tools.deploy.shaker
         run-file
     ] 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-dictionary? "specialized-arrays" vocab and [
         "Stripping specialized arrays" show
@@ -534,6 +541,7 @@ SYMBOL: deploy-vocab
     strip-destructors
     strip-call
     strip-cocoa
+    strip-gtk-icon
     strip-debugger
     strip-ui-error-hook
     strip-specialized-arrays
diff --git a/basis/tools/deploy/shaker/strip-gtk-icon.factor b/basis/tools/deploy/shaker/strip-gtk-icon.factor
new file mode 100644 (file)
index 0000000..c472b3e
--- /dev/null
@@ -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
+    ]
index ba7dd4d95e4f6e6f32a8ea955b561de8ca3fe937..95abb0d875569c56110fdc82820715d2a3067167 100644 (file)
@@ -1,22 +1,12 @@
 ! Copyright (C) 2008 James Cash
 ! See http://factorcode.org/license.txt for BSD license.
-USING: io io.backend io.directories io.files io.files.info.unix
-io.pathnames kernel namespaces sequences system
-tools.deploy.backend tools.deploy.config
-tools.deploy.config.editor vocabs.loader vocabs.metadata ;
+USING: io io.backend io.directories io.files.info.unix kernel
+namespaces sequences system tools.deploy.backend
+tools.deploy.config tools.deploy.config.editor ;
 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 )
-    [ copy-vm ] [ copy-icon ] 2bi
+    copy-vm
     dup OCT: 755 set-file-permissions ;
 
 : bundle-name ( -- str )
index da74a40a88d50439d85096628d36e79320dfa60a..c5b1ff9eeb1e4bc738792bb80e944a872106d036 100644 (file)
@@ -1,16 +1,17 @@
 ! Copyright (C) 2010 Anton Gorenko, Philipp Brüschweiler.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors alien.accessors alien.c-types alien.data
-alien.strings alien.syntax arrays assocs classes.struct
-command-line destructors gdk.ffi gdk.gl.ffi glib.ffi
+alien.strings arrays assocs classes.struct command-line
+destructors gdk.ffi gdk.gl.ffi gdk.pixbuf.ffi glib.ffi
 gobject.ffi gtk.ffi gtk.gl.ffi io.backend
-io.backend.unix.multiplexers io.encodings.utf8 io.thread kernel
-libc literals locals math math.bitwise math.order math.vectors
-namespaces sequences strings system threads ui ui.backend
-ui.clipboards ui.commands ui.event-loop ui.gadgets
-ui.gadgets.editors ui.gadgets.menus ui.gadgets.private
-ui.gadgets.worlds ui.gestures ui.pixel-formats
-ui.pixel-formats.private ui.private ;
+io.backend.unix.multiplexers io.encodings.binary
+io.encodings.utf8 io.files io.thread kernel libc literals
+locals math math.bitwise math.order math.vectors namespaces
+sequences strings system threads ui ui.backend ui.clipboards
+ui.commands ui.event-loop ui.gadgets ui.gadgets.editors
+ui.gadgets.menus ui.gadgets.private ui.gadgets.worlds
+ui.gestures ui.pixel-formats ui.pixel-formats.private
+ui.private ;
 IN: ui.backend.gtk
 
 SINGLETON: gtk-ui-backend
@@ -268,15 +269,16 @@ SYMBOL: next-timeout
     f g_source_attach drop
     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 ( -- )
-    ! This file is not in a resource.txt because it can be
-    ! overwritten when deploying. See 'Vocabulary icons'
-    ! in the docs.
-    "vocab:ui/backend/gtk/icon.png"
-    normalize-path utf8 string>alien
-    { { pointer: GError initial: f } }
-    [ gtk_window_set_default_icon_from_file ] with-out-parameters
-    handle-GError drop ;
+    get-icon-data [
+        data>GInputStream &g_object_unref
+        GInputStream>GdkPixbuf gtk_window_set_default_icon
+    ] with-destructors ;
 
 M: gtk-ui-backend (with-ui)
     [
diff --git a/basis/ui/backend/gtk/icon.png b/basis/ui/backend/gtk/icon.png
deleted file mode 100644 (file)
index a1da637..0000000
Binary files a/basis/ui/backend/gtk/icon.png and /dev/null differ