mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-03 23:18:40 +00:00
[GTKUI] Update methods to latest GTK2 API 2.24
This commit is contained in:
parent
c619674cf9
commit
a5b07aa4ef
2 changed files with 20 additions and 24 deletions
|
@ -130,7 +130,7 @@ class MainWindow(component.Component):
|
||||||
self.vpaned.set_position(self.initial_vpaned_position)
|
self.vpaned.set_position(self.initial_vpaned_position)
|
||||||
self.show()
|
self.show()
|
||||||
while gtk.events_pending():
|
while gtk.events_pending():
|
||||||
gtk.main_iteration(False)
|
gtk.main_iteration()
|
||||||
|
|
||||||
def show(self):
|
def show(self):
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -505,11 +505,7 @@ class CompletionList(ValueList):
|
||||||
|
|
||||||
|
|
||||||
class PathChooserPopup(object):
|
class PathChooserPopup(object):
|
||||||
"""
|
"""This creates the popop window for the ComboEntry."""
|
||||||
|
|
||||||
This creates the popop window for the ComboEntry
|
|
||||||
|
|
||||||
"""
|
|
||||||
def __init__(self, min_visible_rows, max_visible_rows, popup_alignment_widget):
|
def __init__(self, min_visible_rows, max_visible_rows, popup_alignment_widget):
|
||||||
self.min_visible_rows = min_visible_rows
|
self.min_visible_rows = min_visible_rows
|
||||||
# Maximum number of rows to display without scrolling
|
# Maximum number of rows to display without scrolling
|
||||||
|
@ -519,28 +515,28 @@ class PathChooserPopup(object):
|
||||||
self.popup_buttonbox = None # If set, the height of this widget is the minimum height
|
self.popup_buttonbox = None # If set, the height of this widget is the minimum height
|
||||||
|
|
||||||
def popup(self):
|
def popup(self):
|
||||||
"""
|
"""Make the popup visible."""
|
||||||
Makes the popup visible.
|
|
||||||
|
|
||||||
"""
|
|
||||||
# Entry is not yet visible
|
# Entry is not yet visible
|
||||||
if not self.path_entry.flags() & gtk.REALIZED:
|
if not self.path_entry.get_realized():
|
||||||
return
|
return
|
||||||
self.set_window_position_and_size()
|
self.set_window_position_and_size()
|
||||||
|
|
||||||
def popdown(self):
|
def popdown(self):
|
||||||
if not self.is_popped_up():
|
if not self.is_popped_up():
|
||||||
return
|
return
|
||||||
if not self.path_entry.flags() & gtk.REALIZED:
|
if not self.path_entry.get_realized():
|
||||||
return
|
return
|
||||||
self.popup_window.grab_remove()
|
self.popup_window.grab_remove()
|
||||||
self.popup_window.hide_all()
|
self.popup_window.hide_all()
|
||||||
|
|
||||||
def is_popped_up(self):
|
def is_popped_up(self):
|
||||||
|
"""Check if window is popped up.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
bool: True if popped up, False otherwise.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Return True if the window is popped up.
|
return self.popup_window.get_mapped()
|
||||||
"""
|
|
||||||
return bool(self.popup_window.flags() & gtk.MAPPED)
|
|
||||||
|
|
||||||
def set_window_position_and_size(self):
|
def set_window_position_and_size(self):
|
||||||
if len(self.tree_store) < self.min_visible_rows:
|
if len(self.tree_store) < self.min_visible_rows:
|
||||||
|
@ -562,7 +558,7 @@ class PathChooserPopup(object):
|
||||||
self.treeview.realize()
|
self.treeview.realize()
|
||||||
|
|
||||||
# We start with the coordinates of the parent window
|
# We start with the coordinates of the parent window
|
||||||
x, y = self.path_entry.window.get_origin()
|
x, y = self.path_entry.get_window().get_origin()
|
||||||
|
|
||||||
# Add the position of the alignment_widget relative to the parent window.
|
# Add the position of the alignment_widget relative to the parent window.
|
||||||
x += self.alignment_widget.allocation.x
|
x += self.alignment_widget.allocation.x
|
||||||
|
@ -617,7 +613,7 @@ class PathChooserPopup(object):
|
||||||
width = content_width
|
width = content_width
|
||||||
|
|
||||||
screen = self.path_entry.get_screen()
|
screen = self.path_entry.get_screen()
|
||||||
monitor_num = screen.get_monitor_at_window(self.path_entry.window)
|
monitor_num = screen.get_monitor_at_window(self.path_entry.get_window())
|
||||||
monitor = screen.get_monitor_geometry(monitor_num)
|
monitor = screen.get_monitor_geometry(monitor_num)
|
||||||
|
|
||||||
if x < monitor.x:
|
if x < monitor.x:
|
||||||
|
@ -643,15 +639,15 @@ class PathChooserPopup(object):
|
||||||
|
|
||||||
def popup_grab_window(self):
|
def popup_grab_window(self):
|
||||||
activate_time = 0
|
activate_time = 0
|
||||||
if gdk.pointer_grab(self.popup_window.window, True,
|
if gdk.pointer_grab(self.popup_window.get_window(), True,
|
||||||
(gdk.BUTTON_PRESS_MASK |
|
(gdk.BUTTON_PRESS_MASK |
|
||||||
gdk.BUTTON_RELEASE_MASK |
|
gdk.BUTTON_RELEASE_MASK |
|
||||||
gdk.POINTER_MOTION_MASK),
|
gdk.POINTER_MOTION_MASK),
|
||||||
None, None, activate_time) == 0:
|
None, None, activate_time) == 0:
|
||||||
if gdk.keyboard_grab(self.popup_window.window, True, activate_time) == 0:
|
if gdk.keyboard_grab(self.popup_window.get_window(), True, activate_time) == 0:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
self.popup_window.window.get_display().pointer_ungrab(activate_time)
|
self.popup_window.get_window().get_display().pointer_ungrab(activate_time)
|
||||||
return False
|
return False
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -693,7 +689,7 @@ class PathChooserPopup(object):
|
||||||
# be hidden. This is necessary for when the event happens on another
|
# be hidden. This is necessary for when the event happens on another
|
||||||
# widget
|
# widget
|
||||||
toplevel = event.window.get_toplevel()
|
toplevel = event.window.get_toplevel()
|
||||||
parent = self.popup_window.window
|
parent = self.popup_window.get_window()
|
||||||
|
|
||||||
if toplevel != parent:
|
if toplevel != parent:
|
||||||
hide = True
|
hide = True
|
||||||
|
@ -750,7 +746,7 @@ class StoredValuesPopup(StoredValuesList, PathChooserPopup):
|
||||||
PathChooserPopup.popup(self)
|
PathChooserPopup.popup(self)
|
||||||
self.popup_window.grab_focus()
|
self.popup_window.grab_focus()
|
||||||
|
|
||||||
if not self.treeview.flags() & gtk.HAS_FOCUS:
|
if not self.treeview.has_focus():
|
||||||
self.treeview.grab_focus()
|
self.treeview.grab_focus()
|
||||||
if not self.popup_grab_window():
|
if not self.popup_grab_window():
|
||||||
self.popup_window.hide()
|
self.popup_window.hide()
|
||||||
|
@ -871,7 +867,7 @@ class PathCompletionPopup(CompletionList, PathChooserPopup):
|
||||||
PathChooserPopup.popup(self)
|
PathChooserPopup.popup(self)
|
||||||
self.popup_window.grab_focus()
|
self.popup_window.grab_focus()
|
||||||
|
|
||||||
if not self.treeview.flags() & gtk.HAS_FOCUS:
|
if not self.treeview.has_focus():
|
||||||
self.treeview.grab_focus()
|
self.treeview.grab_focus()
|
||||||
|
|
||||||
if not self.popup_grab_window():
|
if not self.popup_grab_window():
|
||||||
|
@ -926,7 +922,7 @@ class PathAutoCompleter(object):
|
||||||
self.accelerator_string = gtk.accelerator_name(keysyms.Tab, 0)
|
self.accelerator_string = gtk.accelerator_name(keysyms.Tab, 0)
|
||||||
|
|
||||||
def on_entry_text_insert_text(self, entry, new_text, new_text_length, position):
|
def on_entry_text_insert_text(self, entry, new_text, new_text_length, position):
|
||||||
if self.path_entry.flags() & gtk.REALIZED:
|
if self.path_entry.get_realized():
|
||||||
cur_text = self.path_entry.get_text()
|
cur_text = self.path_entry.get_text()
|
||||||
pos = entry.get_position()
|
pos = entry.get_position()
|
||||||
new_complete_text = cur_text[:pos] + new_text + cur_text[pos:]
|
new_complete_text = cur_text[:pos] + new_text + cur_text[pos:]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue