Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
c88534cc
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
c88534cc
编写于
7月 15, 2014
作者:
A
azvegint
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8040007: GtkFileDialog strips user inputted filepath
Reviewed-by: anthony, serb
上级
28e6cba4
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
56 addition
and
66 deletion
+56
-66
src/solaris/native/sun/awt/gtk2_interface.c
src/solaris/native/sun/awt/gtk2_interface.c
+2
-0
src/solaris/native/sun/awt/gtk2_interface.h
src/solaris/native/sun/awt/gtk2_interface.h
+1
-1
src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c
src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c
+53
-65
未找到文件。
src/solaris/native/sun/awt/gtk2_interface.c
浏览文件 @
c88534cc
...
...
@@ -783,6 +783,8 @@ gboolean gtk2_load(JNIEnv *env)
fp_gtk_widget_show
=
dl_symbol
(
"gtk_widget_show"
);
fp_gtk_main
=
dl_symbol
(
"gtk_main"
);
fp_g_path_get_dirname
=
dl_symbol
(
"g_path_get_dirname"
);
/**
* GLib thread system
*/
...
...
src/solaris/native/sun/awt/gtk2_interface.h
浏览文件 @
c88534cc
...
...
@@ -817,7 +817,7 @@ gulong (*fp_g_signal_connect_data)(gpointer instance,
void
(
*
fp_gtk_widget_show
)(
GtkWidget
*
widget
);
void
(
*
fp_gtk_main
)(
void
);
guint
(
*
fp_gtk_main_level
)(
void
);
gchar
*
(
*
fp_g_path_get_dirname
)
(
const
gchar
*
file_name
);
/**
* This function is available for GLIB > 2.20, so it MUST be
...
...
src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c
浏览文件 @
c88534cc
...
...
@@ -59,7 +59,6 @@ JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_initIDs
static
gboolean
filenameFilterCallback
(
const
GtkFileFilterInfo
*
filter_info
,
gpointer
obj
)
{
JNIEnv
*
env
;
jclass
cx
;
jstring
filename
;
env
=
(
JNIEnv
*
)
JNU_GetEnv
(
jvm
,
JNI_VERSION_1_2
);
...
...
@@ -158,62 +157,55 @@ JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_setBounds
fp_gdk_threads_leave
();
}
/*
*
*
Convert a GSList to an array of filenames (without the parent folder)
/*
*
baseDir should be freed by user.
*/
static
jobjectArray
toFilenamesArray
(
JNIEnv
*
env
,
GSList
*
list
)
{
jstring
str
;
jclass
stringCls
;
GSList
*
iterator
;
jobjectArray
array
;
int
i
;
char
*
entry
;
static
gboolean
isFromSameDirectory
(
GSList
*
list
,
gchar
**
baseDir
)
{
if
(
NULL
==
list
)
{
return
NULL
;
}
GSList
*
it
=
list
;
gchar
*
prevDir
=
NULL
;
gboolean
isAllDirsSame
=
TRUE
;
stringCls
=
(
*
env
)
->
FindClass
(
env
,
"java/lang/String"
);
if
(
stringCls
==
NULL
)
{
(
*
env
)
->
ExceptionClear
(
env
);
JNU_ThrowInternalError
(
env
,
"Could not get java.lang.String class"
);
return
NULL
;
}
while
(
it
)
{
gchar
*
dir
=
fp_g_path_get_dirname
((
gchar
*
)
it
->
data
);
array
=
(
*
env
)
->
NewObjectArray
(
env
,
fp_gtk_g_slist_length
(
list
),
stringCls
,
NULL
);
if
(
array
==
NULL
)
{
(
*
env
)
->
ExceptionClear
(
env
);
JNU_ThrowInternalError
(
env
,
"Could not instantiate array files array"
);
return
NULL
;
}
if
(
prevDir
&&
strcmp
(
prevDir
,
dir
)
!=
0
)
{
isAllDirsSame
=
FALSE
;
fp_g_free
(
dir
);
break
;
}
i
=
0
;
for
(
iterator
=
list
;
iterator
;
iterator
=
iterator
->
next
)
{
entry
=
(
char
*
)
iterator
->
data
;
entry
=
strrchr
(
entry
,
'/'
)
+
1
;
str
=
(
*
env
)
->
NewStringUTF
(
env
,
entry
);
if
(
str
&&
!
(
*
env
)
->
ExceptionCheck
(
env
))
{
(
*
env
)
->
SetObjectArrayElement
(
env
,
array
,
i
,
str
);
if
(
!
prevDir
)
{
prevDir
=
strdup
(
dir
);
}
i
++
;
fp_g_free
(
dir
);
it
=
it
->
next
;
}
return
array
;
if
(
isAllDirsSame
)
{
*
baseDir
=
prevDir
;
}
else
{
free
(
prevDir
);
*
baseDir
=
strdup
(
"/"
);
}
return
isAllDirsSame
;
}
/**
* Convert a GSList to an array of filenames
(with the parent folder)
* Convert a GSList to an array of filenames
*/
static
jobjectArray
to
PathAndFilenamesArray
(
JNIEnv
*
env
,
GSList
*
list
)
static
jobjectArray
to
FilenamesArray
(
JNIEnv
*
env
,
GSList
*
list
,
jstring
*
jcurrent_folder
)
{
jstring
str
;
jclass
stringCls
;
GSList
*
iterator
;
jobjectArray
array
;
int
i
;
char
*
entry
;
gchar
*
entry
;
gchar
*
baseDir
;
gboolean
isFromSameDir
;
if
(
list
==
NULL
)
{
return
NULL
;
...
...
@@ -233,12 +225,23 @@ static jobjectArray toPathAndFilenamesArray(JNIEnv *env, GSList* list)
return
NULL
;
}
i
=
0
;
for
(
iterator
=
list
;
iterator
;
iterator
=
iterator
->
next
)
{
entry
=
(
char
*
)
iterator
->
data
;
isFromSameDir
=
isFromSameDirectory
(
list
,
&
baseDir
);
//check for leading slash.
if
(
entry
[
0
]
==
'/'
)
{
*
jcurrent_folder
=
(
*
env
)
->
NewStringUTF
(
env
,
baseDir
);
if
(
*
jcurrent_folder
==
NULL
)
{
free
(
baseDir
);
return
NULL
;
}
for
(
iterator
=
list
,
i
=
0
;
iterator
;
iterator
=
iterator
->
next
,
i
++
)
{
entry
=
(
gchar
*
)
iterator
->
data
;
if
(
isFromSameDir
)
{
entry
=
strrchr
(
entry
,
'/'
)
+
1
;
}
else
if
(
entry
[
0
]
==
'/'
)
{
entry
++
;
}
...
...
@@ -246,48 +249,33 @@ static jobjectArray toPathAndFilenamesArray(JNIEnv *env, GSList* list)
if
(
str
&&
!
(
*
env
)
->
ExceptionCheck
(
env
))
{
(
*
env
)
->
SetObjectArrayElement
(
env
,
array
,
i
,
str
);
}
i
++
;
}
free
(
baseDir
);
return
array
;
}
static
void
handle_response
(
GtkWidget
*
aDialog
,
gint
responseId
,
gpointer
obj
)
{
JNIEnv
*
env
;
char
*
current_folder
;
GSList
*
filenames
;
jclass
cx
;
jstring
jcurrent_folder
;
jstring
jcurrent_folder
=
NULL
;
jobjectArray
jfilenames
;
env
=
(
JNIEnv
*
)
JNU_GetEnv
(
jvm
,
JNI_VERSION_1_2
);
current_folder
=
NULL
;
filenames
=
NULL
;
gboolean
full_path_names
=
FALSE
;
if
(
responseId
==
GTK_RESPONSE_ACCEPT
)
{
current_folder
=
fp_gtk_file_chooser_get_current_folder
(
GTK_FILE_CHOOSER
(
aDialog
));
if
(
current_folder
==
NULL
)
{
full_path_names
=
TRUE
;
}
filenames
=
fp_gtk_file_chooser_get_filenames
(
GTK_FILE_CHOOSER
(
aDialog
));
}
if
(
full_path_names
)
{
//This is a hack for use with "Recent Folders" in gtk where each
//file could have its own directory.
jfilenames
=
toPathAndFilenamesArray
(
env
,
filenames
);
jcurrent_folder
=
(
*
env
)
->
NewStringUTF
(
env
,
"/"
);
}
else
{
jfilenames
=
toFilenamesArray
(
env
,
filenames
);
jcurrent_folder
=
(
*
env
)
->
NewStringUTF
(
env
,
current_folder
);
}
jfilenames
=
toFilenamesArray
(
env
,
filenames
,
&
jcurrent_folder
);
if
(
!
(
*
env
)
->
ExceptionCheck
(
env
))
{
(
*
env
)
->
CallVoidMethod
(
env
,
obj
,
setFileInternalMethodID
,
jcurrent_folder
,
jfilenames
);
}
fp_g_free
(
current_folder
);
quit
(
env
,
(
jobject
)
obj
,
TRUE
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录