Commit e24ac101 authored by Cédric Bellegarde's avatar Cédric Bellegarde

Rework zoom handler to show real zoom level in menu

parent 24acfc0d
Pipeline #57774 passed with stage
in 8 minutes and 56 seconds
......@@ -53,7 +53,7 @@ class Server:
args = list(parameters.unpack())
for i, sig in enumerate(self.method_inargs[method_name]):
if sig is 'h':
if sig == 'h':
msg = invocation.get_message()
fd_list = msg.get_unix_fd_list()
args[i] = fd_list.get(args[i])
......
......@@ -174,9 +174,8 @@ class ToolbarMenu(Gtk.PopoverMenu):
@param button as Gtk.Button
"""
webview = self.__window.container.current.webview
App().websettings.set_zoom(100, webview.uri)
webview.update_zoom_level()
button.set_label("100 %")
current = webview.zoom_default()
button.set_label("{} %".format(current))
#######################
# PRIVATE #
......
......@@ -91,19 +91,19 @@ class WebView(WebKit2.WebView):
Update zoom level
"""
try:
zoom_level = App().websettings.get_zoom(self.uri)
if zoom_level is None:
zoom_level = 100
if self.__related_view is None:
zoom_level *= self._window.zoom_level
else:
zoom_level = self._window.zoom_level
if self.__related_view is not None:
window = self.__related_view.get_ancestor(Gtk.Window)
if window is not None and hasattr(window, "zoom_level"):
zoom_level *= window.zoom_level
zoom_level = window.zoom_level
else:
_zoom_level = App().websettings.get_zoom(self.uri) / 100
if _zoom_level is not None:
zoom_level = _zoom_level
except Exception as e:
Logger.error("WebView::update_zoom_level(): %s", e)
Logger.debug("Update zoom level: %s", zoom_level)
self.set_zoom_level(zoom_level / 100)
self.set_zoom_level(zoom_level)
def print(self):
"""
......@@ -119,7 +119,7 @@ class WebView(WebKit2.WebView):
"""
current = App().websettings.get_zoom(self.uri)
if current is None:
current = 100
current = int(self._window.zoom_level * 100)
current += 10
App().websettings.set_zoom(current, self.uri)
self.update_zoom_level()
......@@ -132,7 +132,7 @@ class WebView(WebKit2.WebView):
"""
current = App().websettings.get_zoom(self.uri)
if current is None:
current = 100
current = int(self._window.zoom_level * 100)
current -= 10
if current == 0:
return 10
......@@ -145,8 +145,10 @@ class WebView(WebKit2.WebView):
Reset zoom level
@return current zoom after zoom out
"""
App().websettings.set_zoom(100, self.uri)
current = int(self._window.zoom_level * 100)
App().websettings.set_zoom(current, self.uri)
self.update_zoom_level()
return current
def set_title(self, title):
"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment