patch: get position of paned widget slider



Hi,

I realize that I'm using a very old version of Gtk+, so apologies
in advance if this patch is obsolete. I couldn't get to cvs
through my company's firewall to look at the latest source
either.

In any case, this patch is to return the position of the slider
for the paned window widgets. It is useful if you want to
remember where the user moved the slider.

For example, you can connect the "button_release_event" of the
pane widget to a handler that calls gtk_paned_get_position,
store it in a data structure, and write it to disk upon exit.
Then, when the program is started again, read the value back and
use gtk_paned_set_position. 

In my experience, users hate to adjust everything to their liking 
only to have it reset every time. This patch was the easiest way
I could think of for this functionality.

/Alex

--------8<----------------

diff -ru old/gtkpaned.c new/gtkpaned.c
--- old/gtkpaned.c	Mon Feb 14 15:25:20 2000
+++ new/gtkpaned.c	Thu Nov 16 17:23:59 2000
@@ -521,6 +521,15 @@
   gtk_widget_queue_resize (GTK_WIDGET (paned));
 }
 
+gint
+gtk_paned_get_position    (GtkPaned  *paned)
+{
+  g_return_if_fail (paned != NULL);
+  g_return_if_fail (GTK_IS_PANED (paned));
+
+  return paned->child1_size;
+}
+
 void
 gtk_paned_set_handle_size (GtkPaned *paned,
 			   guint16   size)
diff -ru old/gtkpaned.h new/gtkpaned.h
--- old/gtkpaned.h	Sun Feb 13 00:59:50 2000
+++ new/gtkpaned.h	Thu Nov 16 17:23:13 2000
@@ -100,6 +100,7 @@
 				   gboolean   shrink);
 void    gtk_paned_set_position    (GtkPaned  *paned,
 				   gint       position);
+gint    gtk_paned_get_position    (GtkPaned  *paned);
 void    gtk_paned_set_handle_size (GtkPaned *paned,
 				   guint16   size);
 void    gtk_paned_set_gutter_size (GtkPaned *paned,





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]