[Gtk-sharp-list] TreeView.ScrollToCell bug/patch

Lee Mallabone gnome@fonicmonkey.net
24 Mar 2003 17:50:29 +0000


--=-Jc8l4Pbgzbf3KH/LEFxU
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hi all,

I tried to use ScrollToCell method of Gtk.TreeView but got a crash.

This call allows one of 2 of its parameters to be null. However, the
auto-generated method assumes both are non-null, making the method crash
under certain (valid) circumstances.

Attached is a patch to do the correct thing dependent on which parameter
is null.

There are also a couple of GtkHTML changes in the patch - these are not
intentional and I assume are just due to my source tree tracking the cvs
version of gtkhtml?

Please let me know if the patch is 'commitable'.

Regards,

Lee.


--=-Jc8l4Pbgzbf3KH/LEFxU
Content-Disposition: attachment; filename=treeview.diff
Content-Type: text/x-patch; name=treeview.diff; charset=ANSI_X3.4-1968
Content-Transfer-Encoding: 7bit

Index: api/gtk-api.xml
===================================================================
RCS file: /cvs/public/gtk-sharp/api/gtk-api.xml,v
retrieving revision 1.26
diff -u -r1.26 gtk-api.xml
--- api/gtk-api.xml	22 Feb 2003 04:34:55 -0000	1.26
+++ api/gtk-api.xml	24 Mar 2003 18:00:04 -0000
@@ -8273,7 +8273,7 @@
           <parameter type="GtkTreePath*" name="path"/>
         </parameters>
       </method>
-      <method name="ScrollToCell" cname="gtk_tree_view_scroll_to_cell">
+      <method name="ScrollToCell" cname="gtk_tree_view_scroll_to_cell" hidden="1">
         <return-type type="void"/>
         <parameters>
           <parameter type="GtkTreePath*" name="path"/>
@@ -11862,7 +11862,6 @@
       </parameters>
     </callback>
     <object name="HTML" cname="GtkHTML" parent="GtkLayout">
-      <field cname="editor_bindings" type="GtkBindingSet*"/>
       <field cname="iframe_parent" type="GtkWidget*"/>
       <field cname="frame" type="HTMLObject*"/>
       <field cname="editor_api" type="GtkHTMLEditorAPI*"/>
@@ -12026,6 +12025,10 @@
           <parameter type="GtkHTMLCommandType" name="com_type"/>
         </parameters>
       </signal>
+      <property name="Editable" cname="editable" type="gboolean" doc-string=" _(Whether the html can be edited)" readable="true" writeable="true"/>
+      <property name="Title" cname="title" type="gchar*" doc-string=" _(The title of the current document)" readable="true" writeable="true"/>
+      <property name="DocumentBase" cname="document_base" type="gchar*" doc-string=" _(The base URL for relative references)" readable="true" writeable="true"/>
+      <property name="TargetBase" cname="target_base" type="gchar*" doc-string=" _(The base URL of the targe frame)" readable="true" writeable="true"/>
       <method name="AllowSelection" cname="gtk_html_allow_selection">
         <return-type type="void"/>
         <parameters>
Index: sources/Gtk.metadata
===================================================================
RCS file: /cvs/public/gtk-sharp/sources/Gtk.metadata,v
retrieving revision 1.44
diff -u -r1.44 Gtk.metadata
--- sources/Gtk.metadata	21 Feb 2003 03:44:42 -0000	1.44
+++ sources/Gtk.metadata	24 Mar 2003 18:00:04 -0000
@@ -1191,6 +1191,17 @@
 </rule>
 <rule>
   <class name="GtkTreeView">
+    <method>ScrollToCell</method>
+  </class>
+  <data>
+    <attribute target="method">
+      <name>hidden</name>
+      <value>1</value>
+    </attribute>
+  </data>
+</rule>
+<rule>
+  <class name="GtkTreeView">
     <method>RowActivated</method>
   </class>
   <data>
Index: gtk/TreeView.custom
===================================================================
RCS file: /cvs/public/gtk-sharp/gtk/TreeView.custom,v
retrieving revision 1.5
diff -u -r1.5 TreeView.custom
--- gtk/TreeView.custom	22 Feb 2003 04:34:56 -0000	1.5
+++ gtk/TreeView.custom	24 Mar 2003 18:00:04 -0000
@@ -1,10 +1,25 @@
 // Gtk.TreeView.Custom - Gtk TreeView class customizations
 //
 // Author: Kristian Rietveld <kris@gtk.org>
-//
-// (c) 2002 Kristian Rietveld
+//	   Lee Mallabone <gnome@fonicmonkey.net>
+// (c) 2002 Kristian Rietveld, Lee Mallabone
 //
 // This code is inserted after the automatically generated code.
+
+		[DllImport("libgtk-win32-2.0-0.dll")]
+          	static extern void gtk_tree_view_scroll_to_cell(IntPtr raw, IntPtr path, IntPtr column, bool use_align, float row_align, float col_align);
+
+		/// <summary> ScrollToCell Method </summary>
+		/// <remarks> Scrolls the view to a cell, correctly
+		/// allowing one of 'path' or 'column' to be null.</remarks>
+		public void ScrollToCell(Gtk.TreePath path, Gtk.TreeViewColumn column, bool use_align, float row_align, float col_align) {
+			if (path == null) {
+				gtk_tree_view_scroll_to_cell(Handle, IntPtr.Zero, column.Handle, use_align, row_align, col_align);
+			} else {
+				gtk_tree_view_scroll_to_cell(Handle, path.Handle, IntPtr.Zero, use_align, row_align, col_align);
+			}
+		}
+
 
 
 		[DllImport("libgtk-win32-2.0-0.dll")]

--=-Jc8l4Pbgzbf3KH/LEFxU--