Replace _2BUTTON_PRESS by DOUBLE_BUTTON_PRESS

This commit is contained in:
Nick Hall 2019-01-07 18:12:36 +00:00
parent f4832dd785
commit 50ed9268f9
19 changed files with 56 additions and 33 deletions

View File

@ -1532,7 +1532,8 @@ class MultiTreeView(Gtk.TreeView):
if popup.get_children(): # Show the popup menu:
popup.popup(None, None, None, None, 3, event.time)
return True
elif event.type == Gdk.EventType._2BUTTON_PRESS and event.button == 1:
elif (event.type == Gdk.EventType.DOUBLE_BUTTON_PRESS
and event.button == 1):
model, paths = self.get_selection().get_selected_rows()
for path in paths:
node = model.get_iter(path)

View File

@ -248,7 +248,8 @@ class DbManager(CLIDbManager, ManagedWindow):
treat a double click as if it was OK button press. However, we have
to make sure that an item was selected first.
"""
if event.type == Gdk.EventType._2BUTTON_PRESS and event.button == 1:
if (event.type == Gdk.EventType.DOUBLE_BUTTON_PRESS
and event.button == 1):
if self.connect_btn.get_property('sensitive'):
self.top.response(Gtk.ResponseType.OK)
return True

View File

@ -193,7 +193,8 @@ class ButtonTab(GrampsTab):
Handles the double click on list. If the double click occurs,
the Edit button handler is called
"""
if event.type == Gdk.EventType._2BUTTON_PRESS and event.button == 1:
if (event.type == Gdk.EventType.DOUBLE_BUTTON_PRESS
and event.button == 1):
try:
self.edit_button_clicked(obj)
except WindowActiveError:

View File

@ -110,7 +110,8 @@ class GalleryTab(ButtonTab, DbGUIElement):
Handle the button press event: double click or right click on iconlist.
If the double click occurs, the Edit button handler is called.
"""
if event.type == Gdk.EventType._2BUTTON_PRESS and event.button == 1:
if (event.type == Gdk.EventType.DOUBLE_BUTTON_PRESS
and event.button == 1):
self.edit_button_clicked(obj)
return True
elif is_right_click(event):

View File

@ -241,7 +241,8 @@ class EditMedia(EditPrimary):
return (_('Edit Media Object'), self.get_menu_title())
def button_press_event(self, obj, event):
if event.button == 1 and event.type == Gdk.EventType._2BUTTON_PRESS:
if (event.type == Gdk.EventType.DOUBLE_BUTTON_PRESS
and event.button == 1):
self.view_media(obj)
def view_media(self, obj):

View File

@ -412,7 +412,8 @@ class EditMediaRef(EditReference):
return (_('Media Reference Editor'),submenu_label)
def button_press_event(self, obj, event):
if event.button==1 and event.type == Gdk.EventType._2BUTTON_PRESS:
if (event.type == Gdk.EventType.DOUBLE_BUTTON_PRESS
and event.button == 1):
photo_path = media_path_full(self.db, self.source.get_path())
open_file_with_default_application(photo_path, self.uistate)

View File

@ -608,7 +608,8 @@ class EditPerson(EditPrimary):
main form.
"""
if event.type == Gdk.EventType._2BUTTON_PRESS and event.button == 1:
if (event.type == Gdk.EventType.DOUBLE_BUTTON_PRESS
and event.button == 1):
media_list = self.obj.get_media_list()
if media_list:

View File

@ -702,7 +702,8 @@ class EditRule(ManagedWindow):
self.selection.select_iter(iter)
def _button_press(self, obj, event):
if event.type == Gdk.EventType._2BUTTON_PRESS and event.button == 1:
if (event.type == Gdk.EventType.DOUBLE_BUTTON_PRESS
and event.button == 1):
return self.expand_collapse()
def _key_press(self, obj, event):

View File

@ -481,7 +481,8 @@ class ListModel:
Called when a button press is executed
"""
from .utils import is_right_click
if event.type == Gdk.EventType._2BUTTON_PRESS and event.button == 1:
if (event.type == Gdk.EventType.DOUBLE_BUTTON_PRESS
and event.button == 1):
if self.double_click:
self.double_click(obj)
return True

View File

@ -550,7 +550,8 @@ class PluginStatus(ManagedWindow):
def button_press(self, obj, event):
""" Callback function from the user clicking on a line """
if event.type == Gdk.EventType._2BUTTON_PRESS and event.button == 1:
if (event.type == Gdk.EventType.DOUBLE_BUTTON_PRESS
and event.button == 1):
model, node = self.selection.get_selected()
data = model.get_value(node, 3)
name = model.get_value(node, 1)
@ -560,7 +561,8 @@ class PluginStatus(ManagedWindow):
def button_press_reg(self, obj, event):
""" Callback function from the user clicking on a line in reg plugin
"""
if event.type == Gdk.EventType._2BUTTON_PRESS and event.button == 1:
if (event.type == Gdk.EventType.DOUBLE_BUTTON_PRESS
and event.button == 1):
self.__info(obj, self.list_reg, 4)
def button_press_addon(self, obj):
@ -830,7 +832,7 @@ class ToolManagedWindowBase(ManagedWindow):
if iter.has_tag(tag):
person = self.db.get_person_from_handle(person_handle)
if event.button == 1:
if event.type == Gdk.EventType._2BUTTON_PRESS:
if event.type == Gdk.EventType.DOUBLE_BUTTON_PRESS:
try:
EditPerson(self.dbstate, self.uistate, [], person)
except WindowActiveError:

View File

@ -257,7 +257,8 @@ class BookListDisplay:
Checks for a double click event. In the list, we want to
treat a double click as if it was OK button press.
"""
if event.type == Gdk.EventType._2BUTTON_PRESS and event.button == 1:
if (event.type == Gdk.EventType.DOUBLE_BUTTON_PRESS
and event.button == 1):
store, the_iter = self.blist.get_selected()
if not the_iter:
return False
@ -601,7 +602,8 @@ class BookSelector(ManagedWindow):
Double-click on the current book selection is the same as setup.
Right click evokes the context menu.
"""
if event.type == Gdk.EventType._2BUTTON_PRESS and event.button == 1:
if (event.type == Gdk.EventType.DOUBLE_BUTTON_PRESS
and event.button == 1):
self.on_setup_clicked(obj)
elif is_right_click(event):
self.build_book_context_menu(event)
@ -611,7 +613,8 @@ class BookSelector(ManagedWindow):
Double-click on the available selection is the same as add.
Right click evokes the context menu.
"""
if event.type == Gdk.EventType._2BUTTON_PRESS and event.button == 1:
if (event.type == Gdk.EventType.DOUBLE_BUTTON_PRESS
and event.button == 1):
self.on_add_clicked(obj)
elif is_right_click(event):
self.build_avail_context_menu(event)

View File

@ -160,7 +160,8 @@ class StyleListDisplay(ManagedWindow):
log.error("Failed to save stylesheet", exc_info=True)
def on_button_press(self, obj, event):
if event.type == Gdk.EventType._2BUTTON_PRESS and event.button == 1:
if (event.type == Gdk.EventType.DOUBLE_BUTTON_PRESS
and event.button == 1):
self.on_edit_clicked(obj)
def on_edit_clicked(self, obj):

View File

@ -848,7 +848,8 @@ class ListView(NavigationView):
if not self.dbstate.is_open():
return False
menu = self.uimanager.get_widget('Popup')
if event.type == Gdk.EventType._2BUTTON_PRESS and event.button == 1:
if (event.type == Gdk.EventType.DOUBLE_BUTTON_PRESS
and event.button == 1):
if self.model.get_flags() & Gtk.TreeModelFlags.LIST_ONLY:
self.edit(obj)
return True

View File

@ -644,7 +644,7 @@ class GuiGramplet:
person = self.dbstate.db.get_person_from_handle(handle)
if person is not None:
if event.button == 1: # left mouse
if event.type == Gdk.EventType._2BUTTON_PRESS: # double
if event.type == Gdk.EventType.DOUBLE_BUTTON_PRESS:
try:
EditPerson(self.dbstate,
self.uistate,
@ -652,7 +652,7 @@ class GuiGramplet:
return True # handled event
except WindowActiveError:
pass
elif event.type == Gdk.EventType.BUTTON_PRESS: # single
elif event.type == Gdk.EventType.BUTTON_PRESS:
self.uistate.set_active(handle, 'Person')
return True # handled event
elif is_right_click(event):
@ -666,7 +666,7 @@ class GuiGramplet:
pass
elif link_type == 'Surname':
if event.button == 1: # left mouse
if event.type == Gdk.EventType._2BUTTON_PRESS: # double
if event.type == Gdk.EventType.DOUBLE_BUTTON_PRESS:
run_quick_report_by_name(self.dbstate,
self.uistate,
'samesurnames',
@ -674,7 +674,7 @@ class GuiGramplet:
return True
elif link_type == 'Given':
if event.button == 1: # left mouse
if event.type == Gdk.EventType._2BUTTON_PRESS: # double
if event.type == Gdk.EventType.DOUBLE_BUTTON_PRESS:
run_quick_report_by_name(self.dbstate,
self.uistate,
'samegivens_misc',
@ -682,7 +682,7 @@ class GuiGramplet:
return True
elif link_type == 'Filter':
if event.button == 1: # left mouse
if event.type == Gdk.EventType._2BUTTON_PRESS: # double
if event.type == Gdk.EventType.DOUBLE_BUTTON_PRESS:
run_quick_report_by_name(self.dbstate,
self.uistate,
'filterbyname',
@ -707,7 +707,7 @@ class GuiGramplet:
family = self.dbstate.db.get_family_from_handle(handle)
if family is not None:
if event.button == 1: # left mouse
if event.type == Gdk.EventType._2BUTTON_PRESS: # double
if event.type == Gdk.EventType.DOUBLE_BUTTON_PRESS:
try:
EditFamily(self.dbstate,
self.uistate,
@ -715,7 +715,7 @@ class GuiGramplet:
return True # handled event
except WindowActiveError:
pass
elif event.type == Gdk.EventType.BUTTON_PRESS: # single
elif event.type == Gdk.EventType.BUTTON_PRESS:
self.uistate.set_active(handle, 'Family')
return True # handle event
elif is_right_click(event):
@ -729,7 +729,7 @@ class GuiGramplet:
pass
elif link_type == 'PersonList':
if event.button == 1: # left mouse
if event.type == Gdk.EventType._2BUTTON_PRESS: # double
if event.type == Gdk.EventType.DOUBLE_BUTTON_PRESS:
run_quick_report_by_name(self.dbstate,
self.uistate,
'filterbyname',
@ -738,7 +738,7 @@ class GuiGramplet:
return True
elif link_type == 'Attribute':
if event.button == 1: # left mouse
if event.type == Gdk.EventType._2BUTTON_PRESS: # double
if event.type == Gdk.EventType.DOUBLE_BUTTON_PRESS:
run_quick_report_by_name(self.dbstate,
self.uistate,
'attribute_match',

View File

@ -77,7 +77,8 @@ class Photo(Gtk.EventBox):
"""
Display the image with the default external viewer.
"""
if event.type == Gdk.EventType._2BUTTON_PRESS and event.button == 1:
if (event.type == Gdk.EventType.DOUBLE_BUTTON_PRESS
and event.button == 1):
open_file_with_default_application(self.full_path, self.uistate)
return True
elif is_right_click(event):

View File

@ -124,7 +124,8 @@ class Leak(Gramplet):
# self.display() # We should only run this on demand
def _button_press(self, obj, event):
if event.type == Gdk.EventType._2BUTTON_PRESS and event.button == 1:
if (event.type == Gdk.EventType.DOUBLE_BUTTON_PRESS
and event.button == 1):
self.referenced_in()
return True
elif is_right_click(event):

View File

@ -341,7 +341,8 @@ class RemoveUnused(tool.Tool, ManagedWindow, UpdateCallback):
row[RemoveUnused.MARK_COL] = not row[RemoveUnused.MARK_COL]
def double_click(self, obj, event):
if event.type == Gdk.EventType._2BUTTON_PRESS and event.button == 1:
if (event.type == Gdk.EventType.DOUBLE_BUTTON_PRESS
and event.button == 1):
(model, node) = self.selection.get_selected()
if not node:
return

View File

@ -708,7 +708,8 @@ class VerifyResults(ManagedWindow):
def double_click(self, obj, event):
""" the user wants to edit the selected person or family """
if event.type == Gdk.EventType._2BUTTON_PRESS and event.button == 1:
if (event.type == Gdk.EventType.DOUBLE_BUTTON_PRESS
and event.button == 1):
(model, node) = self.selection.get_selected()
if not node:
return

View File

@ -1478,7 +1478,8 @@ class PedigreeView(NavigationView):
self.cb_build_full_nav_menu(obj, event,
person_handle, family_handle)
return True
elif event.button == 1 and event.type == Gdk.EventType._2BUTTON_PRESS:
elif (event.type == Gdk.EventType.DOUBLE_BUTTON_PRESS
and event.button == 1):
self.cb_edit_person(obj, person_handle)
return True
return True
@ -1492,7 +1493,8 @@ class PedigreeView(NavigationView):
if is_right_click(event):
self.cb_build_relation_nav_menu(obj, event, family_handle)
return True
elif event.button == 1 and event.type == Gdk.EventType._2BUTTON_PRESS:
elif (event.type == Gdk.EventType.DOUBLE_BUTTON_PRESS
and event.button == 1):
self.cb_edit_family(obj, family_handle)
return True
return True
@ -1503,7 +1505,8 @@ class PedigreeView(NavigationView):
Call function for not full family for mouse left button double click
on missing persons or call submenu for mouse right click.
"""
if event.button == 1 and event.type == Gdk.EventType._2BUTTON_PRESS:
if (event.type == Gdk.EventType.DOUBLE_BUTTON_PRESS
and event.button == 1):
self.cb_add_parents(obj, person_handle, family_handle)
return True
elif is_right_click(event):