1 (defpackage :gtk-generation
2 (:use :cl :gobject :cffi :glib)
3 (:export #:gtk-generate
4 #:gtk-generate-child-properties))
6 (in-package :gtk-generation)
8 (load-foreign-library "libgtk-x11-2.0.so")
10 (defcfun gtk-init-check :boolean
11 (argc (:pointer :int))
12 (argv (:pointer (:pointer :string))))
15 (gtk-init-check (foreign-alloc :int :initial-element 0)
16 (foreign-alloc :string :initial-contents '("/usr/bin/sbcl")))
17 #+nil(with-foreign-objects ((argc :int)
18 (argv '(:pointer :string) 1))
19 (setf (mem-ref argc :int) 0
20 (mem-ref argv '(:pointer :string)) (foreign-alloc :string :count 1
21 :initial-element "/usr/bin/sbcl"))
23 (unless (gtk-init-check argc argv)
24 (error "Cannot initialize Gtk+"))
25 (foreign-free (mem-ref argv '(:pointer :string))))))
29 (defcfun gtk-test-register-all-types :void)
31 (gtk-test-register-all-types)
33 (defun gtk-generate (filename)
34 (with-open-file (stream filename :direction :output :if-exists :supersede)
35 (generate-types-hierarchy-to-file
40 :package (or (find-package :gtk) (make-package :gtk))
41 :exceptions `(("GObject" gobject:g-object)
42 ("GtkObject" ,(intern "GTK-OBJECT" (find-package :gtk)))
43 ("GInitiallyUnowned" gobject::g-initially-unowned)
44 ("GtkWindow" ,(intern "GTK-WINDOW" (find-package :gtk)))
45 ("GtkUIManager" ,(intern "UI-MANAGER" (find-package :gtk)))
46 ("GtkUIManagerItemType" ,(intern "UI-MANAGER-ITEM-TYPE" (find-package :gtk))))
47 :prologue (format nil "(in-package :gtk)")
48 :interfaces '("GtkBuildable"
58 "GtkPrintOperationPreview"
63 "AtkImplementorIface")
64 :objects '("GtkSettings" "GtkRcStyle" "GtkStyle" "GtkTooltip" "GtkAccelGroup"
65 "GtkAccelMap" "GtkAction" "GtkActionGroup" "GtkBuilder" "GtkClipboard"
66 "GtkEntryCompletion" "GtkIconFactory" "GtkIconTheme" "GtkIMContext"
67 "GtkListStore" "GtkPageSetup" "GtkPrintContext" "GtkPrintOperation"
68 "GtkPrintSettings" "GtkRecentManager" "GtkSizeGroup" "GtkStatusIcon"
69 "GtkTextBuffer" "GtkTextChildAnchor" "GtkTextMark" "GtkTextTag"
70 "GtkTextTagTable" "GtkTreeModelFilter" "GtkTreeModelSort"
71 "GtkTreeSelection" "GtkTreeStore" "GtkUIManager" "GtkWindowGroup"
72 "GtkToggleAction" "GtkRecentAction" "GtkRadioAction" "GtkItemFactory"
73 "GtkPageSetupUnixDialog" "GtkPrintUnixDialog")
74 :flags '("GtkTextSearchFlags" "GtkAccelFlags" "GtkArgFlags" "GtkAttachOptions"
75 "GtkButtonAction" "GtkCalendarDisplayOptions" "GtkCellRendererState"
76 "GtkDebugFlag" "GtkDestDefaults" "GtkDialogFlags" "GtkFileFilterFlags"
77 "GtkIconLookupFlags" "GtkObjectFlags" "GtkPrivateFlags" "GtkRcFlags"
78 "GtkRecentFilterFlags" "GtkSignalRunType" "GtkTargetFlags"
79 "GtkTreeModelFlags" "GtkUIManagerItemType" "GtkWidgetFlags")
80 :enums '("GtkTextDirection" "GtkSizeGroupMode" "GtkUnit" "GtkPrintStatus"
81 "GtkRecentSortType" "GtkFileChooserAction" "GtkCellRendererAccelMode"
82 "GtkCellRendererMode" "GtkTreeViewColumnSizing"
83 "GtkProgressBarOrientation" "GtkProgressBarStyle" "GtkUpdateType"
84 "GtkMetricType" "GtkSpinButtonUpdatePolicy" "GtkCurveType" "GtkImageType"
85 "GtkArrowType" "GtkSortType" "GtkToolbarStyle" "GtkWrapMode"
86 "GtkJustification" "GtkButtonBoxStyle" "GtkSelectionMode"
87 "GtkTreeViewGridLines" "GtkPackDirection" "GtkPolicyType" "GtkCornerType"
88 "GtkSensitivityType" "GtkShadowType" "GtkIconSize" "GtkOrientation"
89 "GtkPositionType" "GtkReliefStyle" "GtkMessageType" "GtkButtonsType"
90 "GtkWindowType" "GtkWindowPosition" "GtkResizeMode"
91 "GtkTextBufferTargetInfo" "GtkStateType" "GtkDirectionType"
92 "GtkDragResult" "GtkWidgetHelpType" "GtkPackType" "GtkNotebookTab"
93 "GtkMovementStep" "GtkAnchorType" "GtkAssistantPageType"
94 "GtkBuilderError" "GtkCellType" "GtkCListDragPos" "GtkCTreeExpanderStyle"
95 "GtkCTreeExpansionType" "GtkCTreeLineStyle" "GtkCTreePos" "GtkDeleteType"
96 "GtkExpanderStyle" "GtkFileChooserConfirmation" "GtkFileChooserError"
97 "GtkIconThemeError" "GtkIconViewDropPosition" "GtkIMPreeditStyle"
98 "GtkIMStatusStyle" "GtkMatchType" "GtkMenuDirectionType"
99 "GtkNumberUpLayout" "GtkPageOrientation" "GtkPageSet"
100 "GtkPathPriorityType" "GtkPathType" "GtkPreviewType" "GtkPrintDuplex"
101 "GtkPrintError" "GtkPrintOperationAction" "GtkPrintOperationResult"
102 "GtkPrintPages" "GtkPrintQuality" "GtkRcTokenType"
103 "GtkRecentChooserError" "GtkRecentManagerError" "GtkResponseType"
104 "GtkScrollStep" "GtkScrollType" "GtkSideType" "GtkSpinType"
105 "GtkSubmenuDirection" "GtkSubmenuPlacement" "GtkTextWindowType"
106 "GtkToolbarChildType" "GtkToolbarSpaceStyle" "GtkTreeViewDropPosition"
107 "GtkTreeViewMode" "GtkVisibility" "GtkEntryIconPosition")
108 :exclusions '("PangoStretch" "PangoVariant" "PangoStyle" "PangoUnderline" "GtkGLDrawingArea"
109 "GtkCList" "GtkCTree" "GtkCombo" "GtkFileSelection" "GtkItemFactory" "GtkList"
110 "GtkListItem" "GtkOldEditable" "GtkOptionMenu" "GtkPixmap" "GtkPreview"
111 "GtkText" "GtkTooltips" "GtkTipsQuery" "GtkTree" "GtkTreeItem")
112 :additional-properties
114 (:cffi gtk::focus gtk::gtk-window-focus (g-object gtk::widget)
115 "gtk_window_get_focus" "gtk_window_set_focus")
116 (:cffi gtk::default-widget gtk::gtk-window-default-widget (g-object gtk::widget)
117 "gtk_window_get_default_widget" "gtk_window_set_default")
118 (:cffi gtk::has-frame gtk::gtk-window-has-frame :boolean
119 "gtk_window_get_has_frame" "gtk_window_set_has_frame")
120 (:cffi gtk::mnemonic-modifier gtk::gtk-window-mnemonic-modifier (g-object gdk::modifier-type)
121 "gtk_window_get_mnemonic_modifier" "gtk_window_set_mnemonic_modifier")
122 (:cffi gtk::icon-list gtk::gtk-window-icon-list (glist gtk::pixbuf :free-from-foreign t :free-to-foreign t)
123 "gtk_window_get_icon_list" "gtk_window_set_icon_list")
124 (:cffi gtk::group gtk::gtk-window-group (g-object gtk::window-group)
125 "gtk_window_get_group" nil))
127 (:cffi gtk::tree-view gtk::tree-view-column-tree-view g-object
128 "gtk_tree_view_column_get_tree_view" nil)
129 (:cffi gtk::sort-column-id gtk::tree-view-column-sort-column-id :int
130 "gtk_tree_view_column_get_sort_column_id" "gtk_tree_view_column_set_sort_column_id")
131 (:cffi gtk::cell-renderers gtk::tree-view-column-cell-renderers (glist g-object :free-from-foreign t)
132 "gtk_tree_view_column_get_cell_renderers" nil))
134 (:cffi gtk::mode gtk::tree-selection-mode gtk::selection-mode
135 "gtk_tree_selection_get_mode" "gtk_tree_selection_set_mode")
136 (:cffi gtk::select-function gtk::tree-selection-select-function nil
137 gtk::tree-selection-get-selection-function gtk::tree-selection-set-select-function))
139 (:cffi gtk::selection gtk::tree-view-selection g-object
140 "gtk_tree_view_get_selection" nil)
141 (:cffi gtk::column-drag-function gtk::tree-view-column-drag-function nil
142 nil gtk::tree-view-set-column-drag-function)
143 (:cffi gtk::bin-window gtk::tree-view-bin-window g-object
144 "gtk_tree_view_get_bin_window" nil)
145 (:cffi gtk::search-equal-func gtk::tree-view-search-equal-func nil
146 nil gtk::tree-view-set-search-equal-func)
147 (:cffi gtk::search-entry gtk::tree-view-search-entry g-object
148 "gtk_tree_view_get_search_entry" "gtk_tree_view_set_search_entry")
149 (:cffi gtk::search-position-func gtk::tree-view-search-position-func nil
150 nil gtk::tree-view-set-search-position-func)
151 (:cffi gtk::row-separator-func gtk::tree-view-row-separator-func nil
152 nil gtk::tree-view-set-row-separartor-func))
154 (:cffi gtk::displayed-row gtk::cell-view-displayed-row (g-boxed-foreign gtk::tree-path)
155 "gtk_cell_view_get_displayed_row" "gtk_cell_view_set_displayed_row"))
157 (:cffi gtk::active-iter gtk::combo-box-active-iter (g-boxed-foreign gtk::tree-iter)
158 gtk::combo-box-get-active-iter "gtk_combo_box_set_active_iter")
159 (:cffi gtk::row-separator-func gtk::combo-box-separator-func nil
160 nil gtk::combo-box-set-separator-func))
162 (:cffi gtk::screen gtk::menu-screen g-object
163 nil "gtk_menu_set_screen"))
165 (:cffi gtk::expand gtk::tool-item-expand :boolean
166 "gtk_tool_item_get_expand" "gtk_tool_item_set_expand")
167 (:cffi gtk::use-drag-window gtk::tool-item-use-drag-window :boolean
168 "gtk_tool_item_get_use_drag_window" "gtk_tool_item_set_use_drag_window")
169 (:cffi gtk::icon-size gtk::tool-item-icon-size gtk::icon-size
170 "gtk_tool_item_get_icon_size" nil)
171 (:cffi gtk::orientation gtk::tool-item-orientation gtk::orientation
172 "gtk_tool_item_get_orientation" nil)
173 (:cffi gtk::toolbar-style gtk::tool-item-toolbar-style gtk::toolbar-style
174 "gtk_tool_item_get_toolbar_style" nil)
175 (:cffi gtk::relief-style gtk::tool-item-relief-style gtk::relief-style
176 "gtk_tool_item_get_relief_style" nil))
178 (:cffi gtk::arrow-tooltip-text gtk::menu-tool-button-arrow-tooltip-text :string
179 nil "gtk_menu_tool_button_set_arrow_tooltip_text")
180 (:cffi gtk::arrow-tooltip-markup gtk::menu-tool-button-arrow-tooltip-markup :string
181 nil "gtk_menu_tool_button_set_arrow_tooltip_markup"))
183 (:cffi gtk::accel-group gtk::ui-manager-accel-group g-object
184 "gtk_ui_manager_get_accel_group" nil))
186 (:cffi gtk::translate-function gtk::action-group-translate-function nil
187 nil gtk::action-group-set-translate-func)
188 (:cffi gtk::translation-domain gtk::action-group-translation-domain nil
189 nil gtk::gtk-action-group-set-translation-domain))
191 (:cffi gtk::accel-path gtk::action-accel-path (:string :free-from-foreign nil :free-to-foreign t)
192 "gtk_action_get_accel_path" "gtk_action_set_accel_path")
193 (:cffi gtk::accel-group gtk::action-accel-group g-object
194 nil "gtk_action_set_accel_group"))
196 (:cffi gtk::current-name gtk::file-chooser-current-name (:string :free-to-foreign t :encoding :utf-8)
197 nil "gtk_file_chooser_set_current_name")
198 (:cffi gtk::filename gtk::file-chooser-filename (glib:g-string :free-from-foreign t :free-to-foreign t)
199 "gtk_file_chooser_get_filename" "gtk_file_chooser_set_filename")
200 (:cffi gtk::current-folder gtk::file-chooser-current-folder (glib:g-string :free-from-foreign t :free-to-foreign t)
201 "gtk_file_chooser_get_current_folder" "gtk_file_chooser_set_current_folder")
202 (:cffi gtk::uri gtk::file-chooser-uri (glib:g-string :free-from-foreign t :free-to-foreign t)
203 "gtk_file_chooser_get_uri" "gtk_file_chooser_set_uri")
204 (:cffi gtk::current-folder-uri gtk::file-chooser-current-folder-uri (glib:g-string :free-from-foreign t :free-to-foreign t)
205 "gtk_file_chooser_get_current_folder_uri" "gtk_file_chooser_set_current_folder_uri")
206 (:cffi gtk::preview-filename gtk::file-chooser-preview-filename (glib:g-string :free-from-foreign t :free-to-foreign t)
207 "gtk_file_chooser_get_preview_filename" nil)
208 (:cffi gtk::preview-uri gtk::file-chooser-preview-uri (glib:g-string :free-from-foreign t :free-to-foreign t)
209 "gtk_file_chooser_get_preview_uri" nil))
211 (:cffi gtk::name gtk::file-filter-name :string
212 "gtk_file_filter_get_name" "gtk_file_filter_set_name"))
213 ("GtkFontSelectionDialog"
214 (:cffi gtk::font-name gtk::font-selection-dialog-font-name (glib:g-string :free-from-foreign t :free-to-foreign t)
215 "gtk_font_selection_dialog_get_font_name" "gtk_font_selection_dialog_set_font_name")
216 (:cffi gtk::preview-text gtk::font-selection-dialog-preview-text :string
217 "gtk_font_selection_dialog_get_preview_text" "gtk_font_selection_dialog_set_preview_text")
218 (:cffi gtk::apply-button gtk::font-selection-dialog-apply-button g-object
219 "gtk_font_selection_dialog_get_apply_button" nil)
220 (:cffi gtk::cancel-button gtk::font-selection-dialog-cancel-button g-object
221 "gtk_font_selection_dialog_get_cancel_button" nil)
222 (:cffi gtk::ok-button gtk::font-selection-dialog-ok-button g-object
223 "gtk_font_selection_dialog_get_ok_button" nil))
225 (:cffi gtk::has-window gtk::fixed-has-window :boolean
226 "gtk_fixed_get_has_window" "gtk_fixed_set_has_window"))
228 (:cffi gtk::bin-window gtk::layout-bin-window g-object
229 "gtk_layout_get_bin_window" nil))
231 (:cffi gtk::detail-function gtk::calendar-detail-function nil
232 nil gtk::calendar-set-detail-function))
234 (:cffi gtk::focus-child gtk::container-focus-child g-object
235 "gtk_container_get_focus_child" "gtk_container_set_focus_child")
236 (:cffi gtk::focus-vadjustment gtk::container-focus-vadjustment g-object
237 "gtk_container_get_focus_vadjustment" "gtk_container_set_focus_vadjustment")
238 (:cffi gtk::focus-hadjustment gtk::container-focus-hadjustment g-object
239 "gtk_container_get_focus_hadjustment" "gtk_container_set_focus_hadjustment"))
241 (:cffi gtk::parent-window gtk::widget-parent-window (g-object gdk::gdk-window)
242 "gtk_widget_get_parent_window" "gtk_widget_set_parent_window")
243 (:cffi gtk::toplevel gtk::widget-toplevel (g-object gtk::widget)
244 "gtk_widget_get_toplevel" nil)
245 (:cffi gtk::colormap gtk::widget-colormap (g-object gdk::gdk-colormap)
246 "gtk_widget_get_colormap" "gtk_widget_set_colormap")
247 (:cffi gtk::visual gtk::widget-visual (g-object gdk::visual)
248 "gtk_widget_get_visual" nil)
249 (:cffi gtk::modifier-style gtk::widget-modifier-style (g-object gtk::rc-style)
250 "gtk_widget_get_modifier_style" "gtk_widget_modify_style")
251 (:cffi gtk::pango-context gtk::widget-pango-context g-object
252 "gtk_widget_get_pango_context" nil)
253 (:cffi gtk::child-visible gtk::widget-child-visible :boolean
254 "gtk_widget_get_child_visible" "gtk_widget_set_child_visible")
255 (:cffi gtk::direction gtk::widget-direction gtk::text-direction
256 "gtk_widget_get_direction" "gtk_widget_set_direction")
257 (:cffi gtk::composite-name gtk::widget-composite-name (glib:g-string :free-from-foreign t :free-to-foreign t)
258 "gtk_widget_get_composite_name" "gtk_widget_set_composite_name")
259 (:cffi gtk::redraw-on-allocate gtk::widget-redraw-on-allocate :boolean
260 nil "gtk_widget_set_redraw_on_allocate")
261 (:cffi gtk::accessible gtk::widget-accessible g-object
262 "gtk_widget_get_accessible" nil)
263 (:cffi gtk::tooltip-window gtk::widget-tooltip-window g-object
264 "gtk_widget_get_tooltip_window" "gtk_widget_set_tooltip_window"))
266 (:cffi gtk::windows gtk::window-group-windows (glist (g-object gtk::gtk-window))
267 "gtk_window_group_list_windows" nil))
269 (:cffi gtk::priority gtk::text-tag-priority :int
270 "gtk_text_tag_get_priority" "gtk_text_tag_set_priority"))
272 (:cffi gtk::content-area gtk::dialog-content-area (g-object gtk::v-box)
273 "gtk_dialog_get_content_area" nil)
274 (:cffi gtk::action-area gtk::dialog-action-area (g-object gtk::widget)
275 "gtk_dialog_get_action_area" nil)
276 (:cffi gtk::default-response gtk::dialog-default-response gtk::response-type
277 nil "gtk_dialog_set_default_response"))
279 (:cffi gtk::current-page gtk::assistant-current-page :int
280 "gtk_assistant_get_current_page" "gtk_assistant_set_current_page")
281 (:cffi gtk::n-pages gtk::assistant-n-pages :int
282 "gtk_assistant_get_n_pages" nil)
283 (:cffi gtk::forward-page-function gtk::assistant-forward-page-function nil
284 nil gtk::set-assistant-forward-page-function))
286 (:cffi gtk::line-wrap gtk::label-line-wrap :boolean
287 "gtk_label_get_line_wrap" "gtk_label_set_line_wrap")
288 (:cffi gtk::line-wrap-mode gtk::label-line-wrap-mode gtk::pango-wrap-mode
289 "gtk_label_get_line_wrap_mode" "gtk_label_set_line_wrap_mode")
290 (:cffi gtk::layout gtk::label-layout g-object
291 "gtk_label_get_layout" nil)
292 (:cffi gtk::selection-bounds gtk::label-selection-bounds nil
293 gtk::gtk-label-get-selection-bounds nil)
294 (:cffi gtk::layout-offsets gtk::label-layout-offsets nil
295 gtk::gtk-label-get-layout-offsets nil))
297 (:cffi gtk::layout gtk::entry-layout g-object
298 "gtk_entry_get_layout" nil)
299 (:cffi gtk::completion gtk::entry-completion (g-object gtk::entry-completion)
300 "gtk_entry_get_completion" "gtk_entry_set_completion")
301 (:cffi gtk::cursor-hadjustment gtk::entry-cursor-hadjustment (g-object gtk::adjustment)
302 "gtk_entry_get_cursor_hadjustment" "gtk_entry_set_cursor_hadjustment")
303 (:cffi gtk::layout-offset gtk::entry-layout-offset nil
304 gtk::gtk-entry-layout-offset nil))
305 ("GtkPageSetupUnixDialog"
306 (:cffi gtk::page-setup gtk::page-setup-unix-dialog-page-setup (g-object gtk::page-setup)
307 "gtk_page_setup_unix_dialog_get_page_setup" "gtk_page_setup_unix_dialog_set_page_setup")
308 (:cffi gtk::print-settings gtk::page-setup-unix-dialog-print-settings (g-object gtk::print-settings)
309 "gtk_page_setup_unix_dialog_get_print_settings" "gtk_page_setup_unix_dialog_set_print_settings"))
310 ("GtkEntryCompletion"
311 (:cffi gtk::entry gtk::entry-completion-entry (g-object gtk::entry)
312 "gtk_entry_completion_get_entry" nil)
313 (:cffi gtk::match-function gtk::entry-completion-match-function nil
314 nil gtk::gtk-entry-completion-set-match-function))))))
316 (defun gtk-generate-child-properties (filename)
317 (with-open-file (stream filename :direction :output :if-exists :supersede)
318 (let ((*package* (find-package :gtk))
319 (*print-case* :downcase))
320 (write-string "(in-package :gtk)" stream)
322 (format stream "~{~S~%~%~}" (gtk:generate-child-properties)))))