Merge "Add mouse wheel scrolling"

This commit is contained in:
Jenkins 2015-03-26 00:22:39 +00:00 committed by Gerrit Code Review
commit a1a2344dbf
5 changed files with 41 additions and 0 deletions

View File

@ -24,6 +24,7 @@ from gertty import mywid
from gertty import sync
from gertty.view import side_diff as view_side_diff
from gertty.view import unified_diff as view_unified_diff
from gertty.view import mouse_scroll_decorator
import gertty.view
class EditTopicDialog(mywid.ButtonDialog):
@ -389,6 +390,7 @@ class CommitMessageBox(mywid.HyperText):
text = commentlink.run(self.app, text)
super(CommitMessageBox, self).set_text(text)
@mouse_scroll_decorator.ScrollByWheel
class ChangeView(urwid.WidgetWrap):
def help(self):
key = self.app.config.keymap.formatKeys

View File

@ -21,6 +21,7 @@ from gertty import keymap
from gertty import mywid
from gertty import sync
from gertty.view import change as view_change
from gertty.view import mouse_scroll_decorator
import gertty.view
@ -139,6 +140,7 @@ class ChangeListHeader(urwid.WidgetWrap):
for category in categories:
self._w.contents.append((urwid.Text(' %s' % category[0]), self._w.options('given', 2)))
@mouse_scroll_decorator.ScrollByWheel
class ChangeListView(urwid.WidgetWrap):
def help(self):
key = self.app.config.keymap.formatKeys

View File

@ -21,6 +21,7 @@ from gertty import keymap
from gertty import mywid
from gertty import gitrepo
from gertty import sync
from gertty.view import mouse_scroll_decorator
class PatchsetDialog(urwid.WidgetWrap):
signals = ['ok', 'cancel']
@ -145,6 +146,7 @@ class DiffContextButton(urwid.WidgetWrap):
def next(self, button):
self.view.expandChunk(self.diff, self.chunk, from_end=-10)
@mouse_scroll_decorator.ScrollByWheel
class BaseDiffView(urwid.WidgetWrap):
def help(self):
key = self.app.config.keymap.formatKeys

View File

@ -0,0 +1,33 @@
# coding=utf8
#
# Copyright 2014 Jan Kundrát <jkt@kde.org>
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
def mouse_event_scrolling(class_type):
def mouse_event_scrolling(self, size, event, button, col, row, focus):
if event == 'mouse press':
if button == 4:
self.keypress(size, 'up')
return True
if button == 5:
self.keypress(size, 'down')
return True
return super(class_type, self).mouse_event(size, event, button, col,
row, focus)
return mouse_event_scrolling
def ScrollByWheel(original_class):
original_class.mouse_event = mouse_event_scrolling(original_class)
return original_class

View File

@ -20,6 +20,7 @@ from gertty import keymap
from gertty import mywid
from gertty import sync
from gertty.view import change_list as view_change_list
from gertty.view import mouse_scroll_decorator
class ProjectRow(urwid.Button):
project_focus_map = {None: 'focused',
@ -67,6 +68,7 @@ class ProjectListHeader(urwid.WidgetWrap):
(5, urwid.Text(u'Open'))]
super(ProjectListHeader, self).__init__(urwid.Columns(cols))
@mouse_scroll_decorator.ScrollByWheel
class ProjectListView(urwid.WidgetWrap):
def help(self):
key = self.app.config.keymap.formatKeys