OSDN Git Service

not write to adjustment.value of threadview, use vscrollbar.set_value
authorAiwota Programmer <aiwotaprog@tetteke.tk>
Wed, 12 Dec 2007 13:35:05 +0000 (22:35 +0900)
committerAiwota Programmer <aiwotaprog@tetteke.tk>
Wed, 12 Dec 2007 13:35:05 +0000 (22:35 +0900)
src/FukuiNoNamari/thread_view.py

index 7228b60..8a3ff1c 100644 (file)
@@ -40,7 +40,6 @@ class ThreadView(gtk.HBox):
             gtk.gdk.BUTTON_PRESS_MASK |
             gtk.gdk.BUTTON_RELEASE_MASK)
 
-        self.adjustment.step_increment = 20
         self.drawingarea_prev_width = 0
 
         self.drawingarea.connect(
@@ -89,8 +88,7 @@ class ThreadView(gtk.HBox):
         self.set_layout_width(pangolayout)
         self.pangolayout.append(pangolayout)
         x, y = pangolayout.get_pixel_size()
-        self.adjustment.upper = pangolayout.posY + y
-        self.prevent_adjustment_overflow()
+        self.vscrollbar.set_range(0, pangolayout.posY + y)
         self.redraw()
         self.change_vscrollbar_visible()
 
@@ -112,8 +110,7 @@ class ThreadView(gtk.HBox):
             layout.posY = sum_height
             x, y = layout.get_pixel_size()
             sum_height += y
-        self.adjustment.upper = sum_height
-        self.prevent_adjustment_overflow()
+        self.vscrollbar.set_range(0, sum_height)
         self.change_vscrollbar_visible()
 
     def change_vscrollbar_visible(self):
@@ -123,16 +120,14 @@ class ThreadView(gtk.HBox):
             self.vscrollbar.show()
 
     def jump(self, value):
-        if value > self.adjustment.upper - self.adjustment.page_size:
-            value = self.adjustment.upper - self.adjustment.page_size
-        self.adjustment.set_value(value)
+        self.vscrollbar.set_value(value)
 
     def jump_to_layout(self, layout):
         self.jump(layout.posY)
         
     def jump_to_the_end(self):
         value = self.adjustment.upper - self.adjustment.page_size
-        self.adjustment.set_value(value)
+        self.vscrollbar.set_value(value)
 
     def jump_to_res(self, resnum):
         for layout in self.pangolayout:
@@ -142,7 +137,7 @@ class ThreadView(gtk.HBox):
         return False
 
     def draw_viewport(self):
-        view_y = self.adjustment.get_value()
+        view_y = self.vscrollbar.get_value()
         self.drawingarea.window.draw_rectangle(
             self.drawingarea.style.base_gc[0],
             True, 0, 0,
@@ -161,7 +156,7 @@ class ThreadView(gtk.HBox):
                     gc, layout.marginleft, layout.posY - int(view_y), layout)
 
     def transform_coordinate_gdk_to_adj(self, y):
-        return y + self.adjustment.value
+        return y + self.vscrollbar.get_value()
 
     def transform_coordinate_adj_to_layout(self, x, y, layout):
         return x - layout.marginleft, y - layout.posY
@@ -218,20 +213,12 @@ class ThreadView(gtk.HBox):
             self.relayout()
             self.drawingarea_prev_width = allocation.width
         self.adjustment.page_size = self.drawingarea.allocation.height
-        self.adjustment.page_increment = self.drawingarea.allocation.height
+        self.vscrollbar.set_increments(20, self.drawingarea.allocation.height)
 
-        self.prevent_adjustment_overflow()
+        # re-set 'value' for prevent overflow
+        self.vscrollbar.set_value(self.vscrollbar.get_value())
         self.change_vscrollbar_visible()
 
-    def prevent_adjustment_overflow(self):
-        if (self.adjustment.value >
-            self.adjustment.upper - self.adjustment.page_size):
-            self.adjustment.value = (self.adjustment.upper -
-                                     self.adjustment.page_size)
-
-        if self.adjustment.value < 0:
-            self.adjustment.value = 0
-
     def on_vscrollbar_value_changed(self, widget, data=None):
         self.drawingarea.queue_draw()