file-picker.linux: fixing open-file-dialog and save-file-dialog
I had to use utf8 string>alien over utf8 encode because the latter doesnt null-terminate the string.modern-harvey2
parent
0d8338ceb8
commit
e66b1a594a
|
@ -1,8 +1,8 @@
|
||||||
! Copyright (C) 2014, 2015 John Benediktsson.
|
! Copyright (C) 2014, 2015 John Benediktsson.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: alien.c-types alien.data alien.strings alien.syntax
|
USING: accessors alien.c-types alien.strings alien.syntax destructors
|
||||||
destructors file-picker gobject-introspection.standard-types
|
file-picker gobject-introspection.standard-types gtk.ffi
|
||||||
gtk.ffi io.encodings.string io.encodings.utf8 kernel system ;
|
io.encodings.utf8 kernel locals namespaces system ui.gadgets.worlds ;
|
||||||
IN: file-picker.linux
|
IN: file-picker.linux
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
@ -14,29 +14,27 @@ FUNCTION: GtkWidget* gtk_file_chooser_dialog_new (
|
||||||
GtkWindow* parent,
|
GtkWindow* parent,
|
||||||
GtkFileChooserAction action,
|
GtkFileChooserAction action,
|
||||||
gchar* first_button_text,
|
gchar* first_button_text,
|
||||||
gint* first_button_response,
|
gint first_button_response,
|
||||||
gchar* second_button_text,
|
gchar* second_button_text,
|
||||||
gint* second_button_response,
|
gint second_button_response,
|
||||||
void* sentinel )
|
void* sentinel )
|
||||||
|
|
||||||
: <gtk-file-chooser-dialog> ( title action -- dialog )
|
:: <gtk-file-chooser-dialog> ( title action -- dialog )
|
||||||
[
|
title utf8 string>alien
|
||||||
utf8 encode
|
! Current active window becomes the parent
|
||||||
f
|
world get handle>> window>>
|
||||||
GTK_FILE_CHOOSER_ACTION_OPEN
|
GTK_FILE_CHOOSER_ACTION_OPEN
|
||||||
"Cancel" utf8 encode
|
"Cancel" utf8 string>alien
|
||||||
GTK_RESPONSE_CANCEL gint <ref>
|
GTK_RESPONSE_CANCEL
|
||||||
] [
|
action utf8 string>alien
|
||||||
utf8 encode
|
GTK_RESPONSE_ACCEPT
|
||||||
GTK_RESPONSE_ACCEPT gint <ref>
|
|
||||||
f
|
f
|
||||||
gtk_file_chooser_dialog_new
|
gtk_file_chooser_dialog_new >k_widget_destroy ;
|
||||||
>k_widget_destroy
|
|
||||||
] bi* ;
|
|
||||||
|
|
||||||
: run-and-get-filename ( dialog -- path/f )
|
: run-and-get-filename ( dialog -- path/f )
|
||||||
dup gtk_dialog_run GTK_RESPONSE_ACCEPT = [
|
dup gtk_dialog_run GTK_RESPONSE_ACCEPT = [
|
||||||
gtk_file_chooser_get_filename alien>native-string
|
gtk_file_chooser_get_filename utf8 alien>string
|
||||||
] [
|
] [
|
||||||
drop f
|
drop f
|
||||||
] if ;
|
] if ;
|
||||||
|
@ -53,6 +51,6 @@ M: linux save-file-dialog
|
||||||
[
|
[
|
||||||
"Save File" "Save" <gtk-file-chooser-dialog>
|
"Save File" "Save" <gtk-file-chooser-dialog>
|
||||||
dup t gtk_file_chooser_set_do_overwrite_confirmation
|
dup t gtk_file_chooser_set_do_overwrite_confirmation
|
||||||
dup rot gtk_file_chooser_set_filename drop
|
dup rot utf8 string>alien gtk_file_chooser_set_filename drop
|
||||||
run-and-get-filename
|
run-and-get-filename
|
||||||
] with-destructors ;
|
] with-destructors ;
|
||||||
|
|
Loading…
Reference in New Issue