[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-smalltalk] A few comments on the Gtk+ bindings
From: |
Paolo Bonzini |
Subject: |
[Help-smalltalk] A few comments on the Gtk+ bindings |
Date: |
Sat, 18 Sep 2004 15:15:04 +0200 |
User-agent: |
Mozilla Thunderbird 0.5 (Windows/20040207) |
I've started integrating some of your stuff. It's cool.
Changes I'd like to see are:
1) when you modify a method, please please change all occurrences of it.
Blox has a lot of duplicated code, e.g. #font/#font: and the other
property settings.
2) change gtkview to connected, gtkobject to container. gtkobject
should answer "^self connected" (i.e. the gtkview) in all objects but
BViewports; and BViewports should get the implementation you have in
BList and BText (because even though there is duplicated code, existing
hierarchies are there for a purpose :-).
3) rather than modifying the browser, you should as much as possible
disable code in BloxGTK and mark it with FIXMEs. I want to integrate
your stuff with no changes to the browser, or as little as possible:
it's ok OTOH for me to give broken GTK bindings that work ok only for
the browser.
When you've done these, ring me a bell. I'll see when I can do the arch
work to set up my repository, too.
Paolo
--- orig/browser/Manager.st
+++ mod/browser/Manager.st
@@ -105,7 +105,13 @@
| aView |
aView := super new: aString in: view.
aView blox: (BContainer new: view blox).
- ^aView! !
+ ^aView!
+
+horizontal: aString in: view
+ | result |
+ result := self new: aString in: view.
+ result blox setVerticalLayout: false.
+ ^result! !
Manager subclass: #TopLevelShell
--- orig/browser/ModalDialog.st
+++ mod/browser/ModalDialog.st
@@ -42,7 +42,6 @@
!ModalDialog methodsFor: 'displaying'!
display: parent
- blox center.
dialogShell map.
blox loop! !
@@ -160,7 +159,6 @@
receiver: self
message: #cancel.
dialogShell map.
- self blox center.
self blox loop! !
--- orig/browser/Notifier.st
+++ mod/browser/Notifier.st
@@ -62,6 +62,7 @@
process: process.
BLOX BLOXBrowser BrowserMain handleErrorsWithGui: true.
+ (Smalltalk includesKey: #GTK) ifTrue: [ Smalltalk GTK Gtk main ]
] fork.
process suspend.
--- orig/browser/PCode.st
+++ mod/browser/PCode.st
@@ -176,6 +176,10 @@
highlightSyntax
| parser |
+ (source = self contents) ifFalse:
+ [ 'FIXME: this is wrong, something is being dropped elsewhere with
respect to content updates' printNl.
+ source:=self contents
+ ].
parser := STInST.RBParser new
errorBlock: [ :string :pos | ^self ];
initializeParserWith: source type: #on:errorBlock:;
--- orig/browser/PList.st
+++ mod/browser/PList.st
@@ -30,7 +30,7 @@
"
Primitive subclass: #PList
- instanceVariableNames: 'selection selectionMsg listMsg dataMsg '
+ instanceVariableNames: 'selection selectionMsg listMsg dataMsg label'
classVariableNames: ''
poolDictionaries: ''
category: 'Graphics-Windows'!
@@ -38,6 +38,14 @@
PList comment:
nil!
+!PList class methodsFor: 'instance creation' !
+new: aString in: view
+ | result |
+ result:=super new: aString in: view.
+ result label: aString.
+ ^result
+! !
+
!PList methodsFor: 'displaying'!
display
@@ -67,6 +75,10 @@
!PList methodsFor: 'initializing'!
+label: aString
+ label := aString
+!
+
changedSelection: stateChangeKey
"Install message handler for stateChangeKey to select the item based on the
initial selection"
@@ -91,7 +103,7 @@
initialize
selection := 0.
blox := BList new: parentView blox.
- self blox font: 'Helvetica 10'!
+ self blox label: label!
listMsg: listSelector
"Return array of list labels"
--- orig/browser/PText.st
+++ mod/browser/PText.st
@@ -61,6 +61,5 @@
view canBeDirty: true.
view parentView: parent.
view blox: (self bloxClass new: parent blox).
- view blox font: 'Helvetica 10'.
view blox callback: view message: 'setDirtyFlag'.
^view!
@@ -280,7 +283,6 @@
setDirtyFlag
"Set modification state of text view"
-
dirty := canBeDirty!
stateChange: stateChangeKey
--- orig/gtk/GtkDecl.st
+++ mod/gtk/GtkDecl.st
@@ -70,11 +70,31 @@
FileStream fileIn: 'Libs.st'!
FileStream fileIn: 'Types.st'!
+FileStream fileIn: 'MoreStructs.st'!
FileStream fileIn: 'Structs.st'!
FileStream fileIn: 'Enums.st'!
FileStream fileIn: 'Funcs.st'!
FileStream fileIn: 'MoreFuncs.st'!
FileStream fileIn: 'GtkImpl.st'!
GLib registerAllTypes!
Namespace current: Smalltalk!
--- orig/gtk/GtkImpl.st
+++ mod/gtk/GtkImpl.st
@@ -29,6 +29,15 @@
|
======================================================================"
+!GtkWidget methodsFor: 'accessing'!
+
+getSizeRequest
+ "Answer the size the widget has requisitioned."
+ | requisition |
+ requisition := GTK.GtkRequisition new.
+ self sizeRequest: requisition.
+ ^requisition asPoint! !
+
!GtkMessageDialog class methodsFor: 'instance creation'!
new: parent flags: flags type: type buttons: buttons message: message
@@ -64,9 +72,7 @@
!GtkRequisition methodsFor: 'conversion'!
asPoint
- | ba |
- ba := self castTo: (CShortType arrayType: 4).
- ^(ba at: 0) @ (ba at: 1)!
+ ^{self width value. self height value}!
!GdkRectangle class methodsFor: 'instance creation'!
@@ -133,3 +139,76 @@
ba := self castTo: (CShortType arrayType: 4).
^(ba at: 0) @ (ba at: 1) extent:
(ba at: 2) @ (ba at: 3)! !
+
+!GtkTextBuffer methodsFor: 'accessing' !
+
+setText: aString
+ "Set my contents"
+ self setText: aString len: aString size
+!
+
+insertAtCursor: aString
+ "Insert aString at the curser."
+ self insertAtCursor: aString len: aString size!
+
+getText
+ "Answer my entire contents."
+ | start end|
+ start := GTK.GtkTextIter new.
+ end := GTK.GtkTextIter new.
+ self getBounds: start end: end.
+ ^self getText: start end: end includeHiddenChars: true.
+!
+
+getIterAtMark: mark
+ "Answer an iterator for mark"
+ | iter |
+ iter := GTK.GtkTextIter new.
+ self getIterAtMark: iter mark: mark.
+ ^iter
+!
+
+getSelectionBounds
+ "Answer my selection bounds"
+ | start end |
+ start := GTK.GtkTextIter new.
+ end := GTK.GtkTextIter new.
+ self getSelectionBounds: start end: end.
+ ^{start. end}
+!
+
+getIterAtLine: line
+ "Answer an iterator at the beginning of line."
+ | result |
+ result := GTK.GtkTextIter new.
+ self getIterAtLine: result lineNumber: line.
+ ^result!
+
+getIterAtLineOffset: aPoint
+ "Answer an iterator at offset in me."
+ | result |
+ result := GTK.GtkTextIter new.
+ self getIterAtLineOffset: result lineNumber: aPoint y - 1 charOffset:
aPoint x - 1.
+ ^result
+!
+
+getStartIter
+ "Answer a start iterator."
+ | result |
+ result := GTK.GtkTextIter new.
+ self getStartIter: result.
+ ^result
+!
+
+getEndIter
+ "Answer an end iterator"
+ | result |
+ result := GTK.GtkTextIter new.
+ self getEndIter: result.
+ ^result
+!
+
+insertAtCursor: aString
+ "Insert aString at the insertion point."
+ self insertAtCursor: aString len: aString size.
+! !
--- orig/gtk/MoreFuncs.st
+++ mod/gtk/MoreFuncs.st
@@ -164,3 +164,277 @@
withSelectorArgs: 'setOop: iter column: aColumn value: aValue'
returning: #void
args: #( #self #cObject #int #smalltalk )!
+
+
+"FIXME: these should be autogenerated, from knowledge that
GtkFileChooserDialog implements GtkFileChooser"
+
+GtkFileChooserDialog class
+ defineCFunc: 'gtk_file_chooser_error_quark'
+ withSelectorArgs: 'errorQuark'
+ returning: #int
+ args: #( )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_set_action'
+ withSelectorArgs: 'setAction: action'
+ returning: #void
+ args: #( #self #int )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_get_action'
+ withSelectorArgs: 'getAction'
+ returning: #int
+ args: #( #self )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_set_local_only'
+ withSelectorArgs: 'setLocalOnly: localOnly'
+ returning: #void
+ args: #( #self #boolean )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_get_local_only'
+ withSelectorArgs: 'getLocalOnly'
+ returning: #boolean
+ args: #( #self )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_set_select_multiple'
+ withSelectorArgs: 'setSelectMultiple: selectMultiple'
+ returning: #void
+ args: #( #self #boolean )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_get_select_multiple'
+ withSelectorArgs: 'getSelectMultiple'
+ returning: #boolean
+ args: #( #self )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_set_current_name'
+ withSelectorArgs: 'setCurrentName: name'
+ returning: #void
+ args: #( #self #string )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_get_filename'
+ withSelectorArgs: 'getFilename'
+ returning: #string
+ args: #( #self )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_set_filename'
+ withSelectorArgs: 'setFilename: filename'
+ returning: #boolean
+ args: #( #self #string )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_select_filename'
+ withSelectorArgs: 'selectFilename: filename'
+ returning: #boolean
+ args: #( #self #string )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_unselect_filename'
+ withSelectorArgs: 'unselectFilename: filename'
+ returning: #void
+ args: #( #self #string )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_select_all'
+ withSelectorArgs: 'selectAll'
+ returning: #void
+ args: #( #self )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_unselect_all'
+ withSelectorArgs: 'unselectAll'
+ returning: #void
+ args: #( #self )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_get_filenames'
+ withSelectorArgs: 'getFilenames'
+ returning: GSList type
+ args: #( #self )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_set_current_folder'
+ withSelectorArgs: 'setCurrentFolder: filename'
+ returning: #boolean
+ args: #( #self #string )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_get_current_folder'
+ withSelectorArgs: 'getCurrentFolder'
+ returning: #string
+ args: #( #self )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_get_uri'
+ withSelectorArgs: 'getUri'
+ returning: #string
+ args: #( #self )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_set_uri'
+ withSelectorArgs: 'setUri: uri'
+ returning: #boolean
+ args: #( #self #string )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_select_uri'
+ withSelectorArgs: 'selectUri: uri'
+ returning: #boolean
+ args: #( #self #string )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_unselect_uri'
+ withSelectorArgs: 'unselectUri: uri'
+ returning: #void
+ args: #( #self #string )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_get_uris'
+ withSelectorArgs: 'getUris'
+ returning: GSList type
+ args: #( #self )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_set_current_folder_uri'
+ withSelectorArgs: 'setCurrentFolderUri: uri'
+ returning: #boolean
+ args: #( #self #string )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_get_current_folder_uri'
+ withSelectorArgs: 'getCurrentFolderUri'
+ returning: #string
+ args: #( #self )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_set_preview_widget'
+ withSelectorArgs: 'setPreviewWidget: previewWidget'
+ returning: #void
+ args: #( #self #cObject )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_get_preview_widget'
+ withSelectorArgs: 'getPreviewWidget'
+ returning: GtkWidget type
+ args: #( #self )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_set_preview_widget_active'
+ withSelectorArgs: 'setPreviewWidgetActive: active'
+ returning: #void
+ args: #( #self #boolean )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_get_preview_widget_active'
+ withSelectorArgs: 'getPreviewWidgetActive'
+ returning: #boolean
+ args: #( #self )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_set_use_preview_label'
+ withSelectorArgs: 'setUsePreviewLabel: useLabel'
+ returning: #void
+ args: #( #self #boolean )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_get_use_preview_label'
+ withSelectorArgs: 'getUsePreviewLabel'
+ returning: #boolean
+ args: #( #self )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_get_preview_filename'
+ withSelectorArgs: 'getPreviewFilename'
+ returning: #string
+ args: #( #self )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_get_preview_uri'
+ withSelectorArgs: 'getPreviewUri'
+ returning: #string
+ args: #( #self )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_set_extra_widget'
+ withSelectorArgs: 'setExtraWidget: extraWidget'
+ returning: #void
+ args: #( #self #cObject )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_get_extra_widget'
+ withSelectorArgs: 'getExtraWidget'
+ returning: GtkWidget type
+ args: #( #self )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_add_filter'
+ withSelectorArgs: 'addFilter: filter'
+ returning: #void
+ args: #( #self #cObject )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_remove_filter'
+ withSelectorArgs: 'removeFilter: filter'
+ returning: #void
+ args: #( #self #cObject )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_list_filters'
+ withSelectorArgs: 'listFilters'
+ returning: GSList type
+ args: #( #self )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_set_filter'
+ withSelectorArgs: 'setFilter: filter'
+ returning: #void
+ args: #( #self #cObject )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_get_filter'
+ withSelectorArgs: 'getFilter'
+ returning: GtkFileFilter type
+ args: #( #self )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_add_shortcut_folder'
+ withSelectorArgs: 'addShortcutFolder: folder error: error'
+ returning: #boolean
+ args: #( #self #string #cObject )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_remove_shortcut_folder'
+ withSelectorArgs: 'removeShortcutFolder: folder error: error'
+ returning: #boolean
+ args: #( #self #string #cObject )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_list_shortcut_folders'
+ withSelectorArgs: 'listShortcutFolders'
+ returning: GSList type
+ args: #( #self )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_add_shortcut_folder_uri'
+ withSelectorArgs: 'addShortcutFolderUri: uri error: error'
+ returning: #boolean
+ args: #( #self #string #cObject )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_remove_shortcut_folder_uri'
+ withSelectorArgs: 'removeShortcutFolderUri: uri error: error'
+ returning: #boolean
+ args: #( #self #string #cObject )!
+
+GtkFileChooserDialog
+ defineCFunc: 'gtk_file_chooser_list_shortcut_folder_uris'
+ withSelectorArgs: 'listShortcutFolderUris'
+ returning: GSList type
+ args: #( #self )!
+
--- orig/gtk/funcs.awk
+++ mod/gtk/funcs.awk
@@ -52,7 +52,8 @@
type["GFunc"] = "__skip_this__"
type["GWeakNotify"] = "__skip_this__"
type["PangoCoverage"] = "__skip_this__" #FIXME
-
+
+ # FIXME: what about 64-bit architectures?
type["gint8"] = "#int"
type["guint8"] = "#int"
type["gint16"] = "#int"
--- orig/gtk/structs.awk
+++ mod/gtk/structs.awk
@@ -42,9 +42,23 @@
# GtkEditable is a dummy class, so we must set inheritance manually
known_parent["GtkEntry"] = "GtkEditable"
known_parent["GtkEditable"] = "GtkWidget"
+ known_parent["GObject"] = "GTypeInstance"
+ known_parent["GtkObject"] = "GObject"
+ known_parent["GtkTextIter"] = ""
+ known_parent["GtkTreeIter"] = ""
+ known_parent["GSList"] = ""
+ known_parent["GtkRequisition"] = ""
# Here starts the class hierarchy
emitted["CObject"] = ""
+
+ # these need CStruct definitions
+ skip["GObject"]=""
+ skip["GtkObject"]=""
+ skip["GtkTextIter"]=""
+ skip["GtkTreeIter"]=""
+ skip["GSList"]=""
+ skip["GtkRequisition"]=""
}
{
@@ -95,8 +109,8 @@
END {
for (i in classNames)
savedClassNames[i] = classNames[i]
- for (i in savedClassNames)
- emit_struct("CObject", i)
+ for (className in savedClassNames)
+ emit_struct("CObject", className)
}
# strips garbage from string
@@ -138,6 +152,11 @@
if (name in emitted)
return
+ if (name in skip) {
+ emitted[name]=""
+ return
+ }
+
delete classNames[name]
# To fix up the big mess that is GtkEditable ensure here that we emit
--- orig/{arch}/=tagging-method
+++ mod/{arch}/=tagging-method
@@ -141,7 +141,15 @@
junk ^(,.*)$
-precious
^(\+.*|\.gdbinit|\.#ckpts-lock|=build\.*|=install\.*|CVS|CVS\.adm|RCS|RCSLOG|SCCS|TAGS|\.svn)$
+precious
^(\+.*|\.gdbinit|\.#ckpts-lock|=build\.*|=install\.*|CVS|CVS\.adm|RCS|RCSLOG|SCCS|TAGS|\.svn|\.libs|\.deps)$
+precious ^.*\.(o|lo|la)$
+precious ^Makefile(\.in)?$
+precious ^libtool$
+precious ^stamp-h1$
+precious ^(termbold|termnorm)$
+precious ^config\.(h|log|status)$
+precious ^autom4te\.cache$
+precious ^configure$
# Files matching the following regexp are classified as backup files, and
# traversal does not descend into backup directories:
- [Help-smalltalk] A few comments on the Gtk+ bindings,
Paolo Bonzini <=