Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 
 

265 rader
12 KiB

  1. /* GTK - The GIMP Toolkit
  2. * gtkfilechooser.h: Abstract interface for file selector GUIs
  3. * Copyright (C) 2003, Red Hat, Inc.
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2 of the License, or (at your option) any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public
  16. * License along with this library; if not, write to the
  17. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  18. * Boston, MA 02111-1307, USA.
  19. */
  20. #if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
  21. #error "Only <gtk/gtk.h> can be included directly."
  22. #endif
  23. #ifndef __GTK_FILE_CHOOSER_H__
  24. #define __GTK_FILE_CHOOSER_H__
  25. #include <gtk/gtkfilefilter.h>
  26. #include <gtk/gtkwidget.h>
  27. G_BEGIN_DECLS
  28. #define GTK_TYPE_FILE_CHOOSER (gtk_file_chooser_get_type ())
  29. #define GTK_FILE_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_CHOOSER, GtkFileChooser))
  30. #define GTK_IS_FILE_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FILE_CHOOSER))
  31. typedef struct _GtkFileChooser GtkFileChooser;
  32. /**
  33. * GtkFileChooserAction:
  34. * @GTK_FILE_CHOOSER_ACTION_OPEN: Indicates open mode. The file chooser
  35. * will only let the user pick an existing file.
  36. * @GTK_FILE_CHOOSER_ACTION_SAVE: Indicates save mode. The file chooser
  37. * will let the user pick an existing file, or type in a new
  38. * filename.
  39. * @GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER: Indicates an Open mode for
  40. * selecting folders. The file chooser will let the user pick an
  41. * existing folder.
  42. * @GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER: Indicates a mode for creating a
  43. * new folder. The file chooser will let the user name an existing or
  44. * new folder.
  45. *
  46. * Describes whether a #GtkFileChooser is being used to open existing files
  47. * or to save to a possibly new file.
  48. */
  49. typedef enum
  50. {
  51. GTK_FILE_CHOOSER_ACTION_OPEN,
  52. GTK_FILE_CHOOSER_ACTION_SAVE,
  53. GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
  54. GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER
  55. } GtkFileChooserAction;
  56. /**
  57. * GtkFileChooserConfirmation:
  58. * @GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM: The file chooser will present
  59. * its stock dialog to confirm about overwriting an existing file.
  60. * @GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME: The file chooser will
  61. * terminate and accept the user's choice of a file name.
  62. * @GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN: The file chooser will
  63. * continue running, so as to let the user select another file name.
  64. *
  65. * Used as a return value of handlers for the
  66. * #GtkFileChooser::confirm-overwrite signal of a #GtkFileChooser. This
  67. * value determines whether the file chooser will present the stock
  68. * confirmation dialog, accept the user's choice of a filename, or
  69. * let the user choose another filename.
  70. *
  71. * Since: 2.8
  72. */
  73. typedef enum
  74. {
  75. GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM,
  76. GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME,
  77. GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN
  78. } GtkFileChooserConfirmation;
  79. GType gtk_file_chooser_get_type (void) G_GNUC_CONST;
  80. /* GError enumeration for GtkFileChooser */
  81. /**
  82. * GTK_FILE_CHOOSER_ERROR:
  83. *
  84. * Used to get the #GError quark for #GtkFileChooser errors.
  85. */
  86. #define GTK_FILE_CHOOSER_ERROR (gtk_file_chooser_error_quark ())
  87. /**
  88. * GtkFileChooserError:
  89. * @GTK_FILE_CHOOSER_ERROR_NONEXISTENT: Indicates that a file does not exist.
  90. * @GTK_FILE_CHOOSER_ERROR_BAD_FILENAME: Indicates a malformed filename.
  91. * @GTK_FILE_CHOOSER_ERROR_ALREADY_EXISTS: Indicates a duplicate path (e.g. when
  92. * adding a bookmark).
  93. * @GTK_FILE_CHOOSER_ERROR_INCOMPLETE_HOSTNAME:
  94. *
  95. * These identify the various errors that can occur while calling
  96. * #GtkFileChooser functions.
  97. */
  98. typedef enum {
  99. GTK_FILE_CHOOSER_ERROR_NONEXISTENT,
  100. GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
  101. GTK_FILE_CHOOSER_ERROR_ALREADY_EXISTS,
  102. GTK_FILE_CHOOSER_ERROR_INCOMPLETE_HOSTNAME
  103. } GtkFileChooserError;
  104. GQuark gtk_file_chooser_error_quark (void);
  105. /* Configuration
  106. */
  107. void gtk_file_chooser_set_action (GtkFileChooser *chooser,
  108. GtkFileChooserAction action);
  109. GtkFileChooserAction gtk_file_chooser_get_action (GtkFileChooser *chooser);
  110. void gtk_file_chooser_set_local_only (GtkFileChooser *chooser,
  111. gboolean local_only);
  112. gboolean gtk_file_chooser_get_local_only (GtkFileChooser *chooser);
  113. void gtk_file_chooser_set_select_multiple (GtkFileChooser *chooser,
  114. gboolean select_multiple);
  115. gboolean gtk_file_chooser_get_select_multiple (GtkFileChooser *chooser);
  116. void gtk_file_chooser_set_show_hidden (GtkFileChooser *chooser,
  117. gboolean show_hidden);
  118. gboolean gtk_file_chooser_get_show_hidden (GtkFileChooser *chooser);
  119. void gtk_file_chooser_set_do_overwrite_confirmation (GtkFileChooser *chooser,
  120. gboolean do_overwrite_confirmation);
  121. gboolean gtk_file_chooser_get_do_overwrite_confirmation (GtkFileChooser *chooser);
  122. void gtk_file_chooser_set_create_folders (GtkFileChooser *chooser,
  123. gboolean create_folders);
  124. gboolean gtk_file_chooser_get_create_folders (GtkFileChooser *chooser);
  125. /* Suggested name for the Save-type actions
  126. */
  127. void gtk_file_chooser_set_current_name (GtkFileChooser *chooser,
  128. const gchar *name);
  129. /* Filename manipulation
  130. */
  131. #ifdef G_OS_WIN32
  132. /* Reserve old names for DLL ABI backward compatibility */
  133. #define gtk_file_chooser_get_filename gtk_file_chooser_get_filename_utf8
  134. #define gtk_file_chooser_set_filename gtk_file_chooser_set_filename_utf8
  135. #define gtk_file_chooser_select_filename gtk_file_chooser_select_filename_utf8
  136. #define gtk_file_chooser_unselect_filename gtk_file_chooser_unselect_filename_utf8
  137. #define gtk_file_chooser_get_filenames gtk_file_chooser_get_filenames_utf8
  138. #define gtk_file_chooser_set_current_folder gtk_file_chooser_set_current_folder_utf8
  139. #define gtk_file_chooser_get_current_folder gtk_file_chooser_get_current_folder_utf8
  140. #define gtk_file_chooser_get_preview_filename gtk_file_chooser_get_preview_filename_utf8
  141. #define gtk_file_chooser_add_shortcut_folder gtk_file_chooser_add_shortcut_folder_utf8
  142. #define gtk_file_chooser_remove_shortcut_folder gtk_file_chooser_remove_shortcut_folder_utf8
  143. #define gtk_file_chooser_list_shortcut_folders gtk_file_chooser_list_shortcut_folders_utf8
  144. #endif
  145. gchar * gtk_file_chooser_get_filename (GtkFileChooser *chooser);
  146. gboolean gtk_file_chooser_set_filename (GtkFileChooser *chooser,
  147. const char *filename);
  148. gboolean gtk_file_chooser_select_filename (GtkFileChooser *chooser,
  149. const char *filename);
  150. void gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
  151. const char *filename);
  152. void gtk_file_chooser_select_all (GtkFileChooser *chooser);
  153. void gtk_file_chooser_unselect_all (GtkFileChooser *chooser);
  154. GSList * gtk_file_chooser_get_filenames (GtkFileChooser *chooser);
  155. gboolean gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
  156. const gchar *filename);
  157. gchar * gtk_file_chooser_get_current_folder (GtkFileChooser *chooser);
  158. /* URI manipulation
  159. */
  160. gchar * gtk_file_chooser_get_uri (GtkFileChooser *chooser);
  161. gboolean gtk_file_chooser_set_uri (GtkFileChooser *chooser,
  162. const char *uri);
  163. gboolean gtk_file_chooser_select_uri (GtkFileChooser *chooser,
  164. const char *uri);
  165. void gtk_file_chooser_unselect_uri (GtkFileChooser *chooser,
  166. const char *uri);
  167. GSList * gtk_file_chooser_get_uris (GtkFileChooser *chooser);
  168. gboolean gtk_file_chooser_set_current_folder_uri (GtkFileChooser *chooser,
  169. const gchar *uri);
  170. gchar * gtk_file_chooser_get_current_folder_uri (GtkFileChooser *chooser);
  171. /* GFile manipulation */
  172. GFile * gtk_file_chooser_get_file (GtkFileChooser *chooser);
  173. gboolean gtk_file_chooser_set_file (GtkFileChooser *chooser,
  174. GFile *file,
  175. GError **error);
  176. gboolean gtk_file_chooser_select_file (GtkFileChooser *chooser,
  177. GFile *file,
  178. GError **error);
  179. void gtk_file_chooser_unselect_file (GtkFileChooser *chooser,
  180. GFile *file);
  181. GSList * gtk_file_chooser_get_files (GtkFileChooser *chooser);
  182. gboolean gtk_file_chooser_set_current_folder_file (GtkFileChooser *chooser,
  183. GFile *file,
  184. GError **error);
  185. GFile * gtk_file_chooser_get_current_folder_file (GtkFileChooser *chooser);
  186. /* Preview widget
  187. */
  188. void gtk_file_chooser_set_preview_widget (GtkFileChooser *chooser,
  189. GtkWidget *preview_widget);
  190. GtkWidget *gtk_file_chooser_get_preview_widget (GtkFileChooser *chooser);
  191. void gtk_file_chooser_set_preview_widget_active (GtkFileChooser *chooser,
  192. gboolean active);
  193. gboolean gtk_file_chooser_get_preview_widget_active (GtkFileChooser *chooser);
  194. void gtk_file_chooser_set_use_preview_label (GtkFileChooser *chooser,
  195. gboolean use_label);
  196. gboolean gtk_file_chooser_get_use_preview_label (GtkFileChooser *chooser);
  197. char *gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser);
  198. char *gtk_file_chooser_get_preview_uri (GtkFileChooser *chooser);
  199. GFile *gtk_file_chooser_get_preview_file (GtkFileChooser *chooser);
  200. /* Extra widget
  201. */
  202. void gtk_file_chooser_set_extra_widget (GtkFileChooser *chooser,
  203. GtkWidget *extra_widget);
  204. GtkWidget *gtk_file_chooser_get_extra_widget (GtkFileChooser *chooser);
  205. /* List of user selectable filters
  206. */
  207. void gtk_file_chooser_add_filter (GtkFileChooser *chooser,
  208. GtkFileFilter *filter);
  209. void gtk_file_chooser_remove_filter (GtkFileChooser *chooser,
  210. GtkFileFilter *filter);
  211. GSList *gtk_file_chooser_list_filters (GtkFileChooser *chooser);
  212. /* Current filter
  213. */
  214. void gtk_file_chooser_set_filter (GtkFileChooser *chooser,
  215. GtkFileFilter *filter);
  216. GtkFileFilter *gtk_file_chooser_get_filter (GtkFileChooser *chooser);
  217. /* Per-application shortcut folders */
  218. gboolean gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
  219. const char *folder,
  220. GError **error);
  221. gboolean gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
  222. const char *folder,
  223. GError **error);
  224. GSList *gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser);
  225. gboolean gtk_file_chooser_add_shortcut_folder_uri (GtkFileChooser *chooser,
  226. const char *uri,
  227. GError **error);
  228. gboolean gtk_file_chooser_remove_shortcut_folder_uri (GtkFileChooser *chooser,
  229. const char *uri,
  230. GError **error);
  231. GSList *gtk_file_chooser_list_shortcut_folder_uris (GtkFileChooser *chooser);
  232. G_END_DECLS
  233. #endif /* __GTK_FILE_CHOOSER_H__ */