Commit 1d345a08 authored by Cédric Bellegarde's avatar Cédric Bellegarde

Rework PagesManagerChild UI

parent b4912d5f
......@@ -2,6 +2,13 @@
<!-- Generated with glade 3.20.0 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="icon_name">window-close-symbolic</property>
</object>
<object class="GtkEventBox" id="widget">
<property name="visible">True</property>
<property name="can_focus">False</property>
......@@ -33,18 +40,20 @@
<property name="valign">end</property>
<property name="vexpand">True</property>
<child>
<object class="GtkEventBox" id="close">
<object class="GtkButton" id="close_button">
<property name="visible">True</property>
<property name="can_focus">False</property>
<signal name="button-press-event" handler="_on_close_button_press_event" swapped="no"/>
<child>
<object class="GtkImage" id="image_close">
<property name="width_request">22</property>
<property name="height_request">22</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
</child>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="margin_left">1</property>
<property name="margin_right">1</property>
<property name="margin_top">1</property>
<property name="margin_bottom">1</property>
<property name="image">image1</property>
<property name="relief">none</property>
<signal name="clicked" handler="_on_close_button_clicked" swapped="no"/>
<style>
<class name="no-padding"/>
</style>
</object>
<packing>
<property name="left_attach">1</property>
......
......@@ -33,11 +33,6 @@
background-color: shade(@theme_bg_color, 1.7);
}
.sidebar-item-close {
background-color: transparent;
color: @theme_fg_color;
}
.sidebar-item {
border: 1px solid alpha(@theme_fg_color, 0.5);
background-color: shade(@theme_bg_color, 1.7);
......
......@@ -43,21 +43,25 @@ class PagesManagerChild(Gtk.FlowBoxChild):
self.__title.set_hexpand(True)
self.__title.set_margin_right(4)
self.__title.set_property("halign", Gtk.Align.CENTER)
self.__title.set_property("valign", Gtk.Align.CENTER)
self.__title.set_ellipsize(Pango.EllipsizeMode.END)
self.__title.show()
builder.get_object("grid").attach(self.__title, 0, 0, 1, 1)
self.__image = builder.get_object("image")
self.__image_close = builder.get_object("image_close")
self.__close_button = builder.get_object("close_button")
self.__audio_indicator = builder.get_object("audio_indicator")
if view.webview.is_playing_audio():
self.__audio_indicator.show()
if view.webview.ephemeral:
self.__image_close.set_from_icon_name("window-close-symbolic",
self.__close_button.get_image().set_from_icon_name(
"window-close-symbolic",
Gtk.IconSize.INVALID)
else:
self.__image_close.set_from_icon_name("applications-internet",
self.__close_button.get_image().set_from_icon_name(
"applications-internet",
Gtk.IconSize.INVALID)
self.__image_close.set_property("pixel-size", ArtSize.FAVICON)
self.__close_button.get_image().set_property("pixel-size",
ArtSize.FAVICON)
self.__spinner = builder.get_object("spinner")
self.add(builder.get_object("widget"))
......@@ -158,11 +162,10 @@ class PagesManagerChild(Gtk.FlowBoxChild):
"""
pass
def _on_close_button_press_event(self, eventbox, event):
def _on_close_button_clicked(self, button):
"""
Destroy self
@param eventbox as Gtk.EventBox
@param event as Gdk.Event
@param button as Gtk.Button
"""
self.__window.container.pages_manager.close_view(self.__view)
return True
......@@ -173,9 +176,9 @@ class PagesManagerChild(Gtk.FlowBoxChild):
@param eventbox as Gtk.EventBox
@param event as Gdk.Event
"""
self.__image_close.set_from_icon_name("window-close-symbolic",
self.__close_button.get_image().set_from_icon_name(
"window-close-symbolic",
Gtk.IconSize.INVALID)
self.__image_close.get_style_context().add_class("sidebar-item-close")
def _on_leave_notify_event(self, eventbox, event):
"""
......@@ -188,8 +191,6 @@ class PagesManagerChild(Gtk.FlowBoxChild):
event.x >= allocation.width or\
event.y <= 0 or\
event.y >= allocation.height:
self.__image_close.get_style_context().remove_class(
"sidebar-item-close")
self.__set_favicon()
#######################
......@@ -206,7 +207,8 @@ class PagesManagerChild(Gtk.FlowBoxChild):
uri,
self.__view.webview.ephemeral)
if artwork is not None:
self.__image_close.set_from_icon_name(artwork,
self.__close_button.get_image().set_from_icon_name(
artwork,
Gtk.IconSize.INVALID)
elif surface is not None:
resized = resize_favicon(surface)
......@@ -215,9 +217,10 @@ class PagesManagerChild(Gtk.FlowBoxChild):
self.__set_favicon_related(resized,
uri,
self.__view.webview.initial_uri)
self.__image_close.set_from_surface(resized)
self.__close_button.get_image().set_from_surface(resized)
else:
self.__image_close.set_from_icon_name("applications-internet",
self.__close_button.get_image().set_from_icon_name(
"applications-internet",
Gtk.IconSize.INVALID)
if resized is not None:
self.__window.container.sites_manager.set_favicon(
......
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