Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2004:
[Freeciv-Dev] (PR#3470) Gtk1 chat scrollbar fix
Home

[Freeciv-Dev] (PR#3470) Gtk1 chat scrollbar fix

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: a-l@xxxxxxx
Subject: [Freeciv-Dev] (PR#3470) Gtk1 chat scrollbar fix
From: "Vasco Alexandre da Silva Costa" <vasc@xxxxxxxxxxxxxx>
Date: Wed, 31 Mar 2004 17:17:03 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=3470 >

> [ali - Wed Feb 19 02:47:44 2003]:
> 
> When you scroll back to read previous messages, focus should stay there
> until you move the scrollbar near the bottom, at which point the 
> scrolling resumes. Just like in a KDE terminal window.

Made port of the patch to GTK+ 2.x.

Index: client/gui-gtk-2.0/chatline.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/chatline.c,v
retrieving revision 1.8
diff -u -r1.8 chatline.c
--- client/gui-gtk-2.0/chatline.c       18 Jul 2003 22:02:25 -0000      1.8
+++ client/gui-gtk-2.0/chatline.c       1 Apr 2004 01:16:29 -0000
@@ -69,20 +69,34 @@
 **************************************************************************/
 void real_append_output_window(const char *astring)
 {
-  GtkTextBuffer *buf;
-  GtkTextIter i;
-  GtkTextMark *mark;
+ GtkWidget *sw;
+ GtkAdjustment *slider;
+ bool scroll;
+
+ GtkTextBuffer *buf;
+ GtkTextIter i;
   
+ sw = gtk_widget_get_parent(GTK_WIDGET(main_message_area));
+ slider = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(sw));
+
+ /* scroll forward only if slider is near the bottom */
+ scroll = ((slider->value + slider->page_size) >=
+          (slider->upper - slider->step_increment));
+
   buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(main_message_area));
   gtk_text_buffer_get_end_iter(buf, &i);
   gtk_text_buffer_insert(buf, &i, "\n", -1);
   gtk_text_buffer_insert(buf, &i, astring, -1);
 
   /* have to use a mark, or this won't work properly */
-  gtk_text_buffer_get_end_iter(buf, &i);
-  mark = gtk_text_buffer_create_mark(buf, NULL, &i, FALSE);
-  gtk_text_view_scroll_mark_onscreen(GTK_TEXT_VIEW(main_message_area), mark);
-  gtk_text_buffer_delete_mark(buf, mark);
+  if (scroll) {
+    GtkTextMark *mark;
+
+    gtk_text_buffer_get_end_iter(buf, &i);
+    mark = gtk_text_buffer_create_mark(buf, NULL, &i, FALSE);
+    gtk_text_view_scroll_mark_onscreen(GTK_TEXT_VIEW(main_message_area), mark);
+    gtk_text_buffer_delete_mark(buf, mark);
+  }
 }
 
 /**************************************************************************

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#3470) Gtk1 chat scrollbar fix, Vasco Alexandre da Silva Costa <=