OSDN Git Service

A numer of res can be popped up. (#16447)
authorAiwota Programmer <aiwotaprog@tetteke.tk>
Wed, 29 Apr 2009 14:06:38 +0000 (23:06 +0900)
committerAiwota Programmer <aiwotaprog@tetteke.tk>
Wed, 29 Apr 2009 14:06:38 +0000 (23:06 +0900)
src/FukuiNoNamari/thread_popup.py

index 9692f8f..fbb71d2 100644 (file)
@@ -60,13 +60,24 @@ class ThreadPopup(gobject.GObject):
         idx = self._thread_view_list.index(widget)
         if idx != len(self._thread_view_list)-1 and orig_uri == self._thread_view_list[idx+1].get_toplevel().uri:
             return
+        if not self._check_to_need_hint(widget):
+            return
         if uri != strict_uri and uri.startswith(strict_uri):
             resnum = uri[len(strict_uri):]
+            match = re.match("(?P<left>\d+)-(?P<right>\d+)", resnum)
+            if match:
+                left = int(match.group("left"))
+                right = int(match.group("right"))
+                if left >= right:
+                    resnum = range(left, right+1)
+                else:
+                    resnum = range(right, left-1, -1)
+                self._show_hint(widget, resnum, orig_uri)
+                return
             match = re.match("\d+", resnum)
             if match:
-                resnum = int(match.group())
-                if self._check_to_need_hint(widget, resnum):
-                    self._show_hint(widget, resnum, orig_uri)
+                resnum = [int(match.group())]
+                self._show_hint(widget, resnum, orig_uri)
 
     def _get_owner(self, gdk_win):
         top = gdk_win.get_toplevel()
@@ -108,7 +119,7 @@ class ThreadPopup(gobject.GObject):
 
         return True
 
-    def _show_hint(self, threadview, num, uri):
+    def _show_hint(self, threadview, numlist, uri):
         top = threadview.get_toplevel()
         relative_x, relative_y = top.get_pointer()
         gdk_win_x, gdk_win_y = top.window.get_origin()
@@ -124,13 +135,15 @@ class ThreadPopup(gobject.GObject):
         # set width
         view.drawingarea.size_allocate(gtk.gdk.Rectangle(0, 0, 300, 200))
 
-        for layout in self._thread_view_list[0].res_layout_list:
-            # skip empty line
-            if isinstance(layout.element_list[0], thread_view.ElementEmpty):
-                continue
-            if layout.resnum == num:
-                clone = layout.clone()
-                view.add_layout(clone)             
+
+        for num in numlist:
+            for layout in self._thread_view_list[0].res_layout_list:
+                # skip empty line
+                if isinstance(layout.element_list[0], thread_view.ElementEmpty):
+                    continue
+                if layout.resnum == num:
+                    clone = layout.clone()
+                    view.add_layout(clone)
         popupwin.view = view
         popupwin.uri = uri
         popupwin.add(view)
@@ -161,7 +174,7 @@ class ThreadPopup(gobject.GObject):
             self._timer_started = True
             gobject.timeout_add(ThreadPopup._INTERVAL, self.on_timeout)
 
-    def _check_to_need_hint(self, threadview, num):
+    def _check_to_need_hint(self, threadview):
         if self._is_thread_view_top(threadview):
             return True