gtk编程,如果用gtk_file_chooser或者其它控件设置一个保存路径

l360220954 2014-11-14 09:17:56
大家好,我现在在用gtk进行开发,现在有一个需求是设置一个保存路径,但是我在用gtkfilechooser的时候,它会去选择一个文件,我没有发现怎么去设置一个路径的API,想问下得到一个路径应该用哪些函数呢,谢谢
...全文
836 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
l360220954 2015-01-23
  • 打赏
  • 举报
回复
引用 7 楼 daixiang28 的回复:
gtk_file_chooser_dialog_new的第三个参数改为GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER就可以了
还不行呢,这样只是让文件夹下面的文件不能点击进行选择了,还不能把这样文件置灰,也就是不能点的状态.我看到midori浏览器可以做到那样了,就是可以达到我想要实现的效果的,同时midori浏览器的界面也是用gtk来实现的,但是我研究不透他们是怎么实现这一功能的. 哎,我现在还是只能让文件夹下的那些文件不能被选择,但还是不能把这些文件置灰.
daixiang28 2015-01-22
  • 打赏
  • 举报
回复
gtk_file_chooser_dialog_new的第三个参数改为GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER就可以了
l360220954 2014-11-17
  • 打赏
  • 举报
回复
还没有答案,继续等,gtkFileChooser对话框,怎么只显示和选择目录,而不能显示文件或者可以显示文件,但把文件置为不可选择的状态(置灰)。
赵4老师 2014-11-14
  • 打赏
  • 举报
回复
gtk没弄过。 Windows: Dialog Box Types The Common Dialog Box Library provides a creation function and a structure for each type of common dialog box. To use a common dialog box in its simplest form, you call its creation function and specify a pointer to a structure containing initial values and option flags. After initializing the dialog box, the dialog box procedure uses the structure to return information about the user's input. You can also customize a common dialog box to suit the needs of your application. The following table provides a brief description of the different types of common dialog boxes, and shows the function and structure used with each type. Common Dialog Box Description Color Displays available colors and optionally lets the user create custom colors. The user can select a basic or custom color. Use the ChooseColor function and CHOOSECOLOR structure. Find Displays a dialog box in which the user can type the string to find. The user can also specify search options, such as the search direction and whether the search is case sensitive. Use the FindText function and FINDREPLACE structure. Font Displays lists of available fonts, point sizes, and other font attributes that the user can select. Use the ChooseFont function and CHOOSEFONT structure. Open Displays lists of drives, directories, and filename extensions from which the user can select to display a list of filenames. The user can type a filename or select one from the list to identify the file to be opened. Use the GetOpenFileName function and OPENFILENAME structure. Print Displays information about the installed printer and its configuration. The user can select print job options, such as the range of pages to print and the number of copies, and start the printing process. Use the PrintDlg function and PRINTDLG structure. Windows NT 5.0 and later: To display a Print property sheet rather than a Print dialog box, use the PrintDlgEx function with the PRINTDLGEX structure. The General page of the property sheet is similar to the Print dialog box. The property sheet can also have additional application-specific and driver-specific property pages following the General page. Page Setup Displays the current page configuration. The user can select page configuration options, such as paper orientation, size, source, and margins. Use the PageSetupDlg function and PAGESETUPDLG structure. Replace Displays a dialog box in which the user can type the string to find and the replacement string. The user can specify search options, such as whether the search is case sensitive, and replacement options, such as the scope of replacement. Use the ReplaceText function and FINDREPLACE structure. Save As Displays lists of drives, directories, and filename extensions from which the user can select to display a list of filenames. The user can type a filename or select one from the list to specify the name with which to save the file. Use the GetSaveFileName function and OPENFILENAME structure. Note Although a Print Setup dialog box is also available, it has been superseded by the Page Setup dialog box. New applications written for Windows 95 or for Windows NT versions 3.51 or later should use the Page Setup dialog box rather than the Print Setup dialog box. All common dialog boxes are modal, except the Find and Replace dialog boxes. Modal dialog boxes must be closed by the user before the function used to create the dialog box can return. The Find and Replace dialog boxes are modeless; the function returns before the dialog box closes. If you use the Find and Replace dialog boxes, you must also use the IsDialogMessage function in the main message loop of your application to ensure that these dialog boxes correctly process keyboard input, such as the tab and esc keys.
l360220954 2014-11-14
  • 打赏
  • 举报
回复
引用 3 楼 zhao4zhong1 的回复:
system("dir /b /a-d c:\\*.* >d:\\allfiles.txt"); //读文件d:\\allfiles.txt的内容即C:\\下所有文件的名字 system("dir /b /a-d /s c:\\*.* >d:\\allfilesinsub.txt"); //读文件d:\\allfilesinsub.txt的内容即C:\\下所有文件的名字包含子目录 system("dir /b /ad c:\\*.* >d:\\alldirs.txt"); //读文件d:\\alldirs.txt的内容即C:\\下所有子目录的名字 请记住,能用shell命令获取文件、文件夹信息或者操作文件、文件夹最好用shell命令获取或者操作,而不要用各种API获取或者操作,因为当遇到非法文件夹名或非法文件名或非法文件长度、非法文件日期、压缩文件、链接文件、稀疏文件……等各种意料之外的情况时,API会处理的不全面或陷入死循环,而shell命令不会。
不知道你说的是什么意思,我问的是Gtk编程呢,应该只是一个gtk相关函数的问题。
赵4老师 2014-11-14
  • 打赏
  • 举报
回复
system("dir /b /a-d c:\\*.* >d:\\allfiles.txt"); //读文件d:\\allfiles.txt的内容即C:\\下所有文件的名字 system("dir /b /a-d /s c:\\*.* >d:\\allfilesinsub.txt"); //读文件d:\\allfilesinsub.txt的内容即C:\\下所有文件的名字包含子目录 system("dir /b /ad c:\\*.* >d:\\alldirs.txt"); //读文件d:\\alldirs.txt的内容即C:\\下所有子目录的名字 请记住,能用shell命令获取文件、文件夹信息或者操作文件、文件夹最好用shell命令获取或者操作,而不要用各种API获取或者操作,因为当遇到非法文件夹名或非法文件名或非法文件长度、非法文件日期、压缩文件、链接文件、稀疏文件……等各种意料之外的情况时,API会处理的不全面或陷入死循环,而shell命令不会。
l360220954 2014-11-14
  • 打赏
  • 举报
回复
现在我可以实现只选择目录而不选择目录下面的各种文件,只是文件夹下面的文件还是能够显示得出来的,但是这里我只要显示出它的目录就好了,目录下面的各种类型的文件是需要显示出来的,用过滤器可以实现这样的功能吗,过滤器好像只是可以选择文件显示的类型的,而不能让所有类型的文件都显示不出来吧?
l360220954 2014-11-14
  • 打赏
  • 举报
回复
要实现的功能就像是word里的另存为那个样子,只显示到保存在的文件夹名,而不在chooser里显示出该文件夹下的文件

3,881

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 其它技术问题
社区管理员
  • 其它技术问题社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧