Commit 69a82761 authored by GabMus's avatar GabMus

switched headerbar to handyheaderbar and stackswitcher to handystackswitcher

parent e9b2de50
Pipeline #71028267 passed with stage
in 1 minute and 45 seconds
......@@ -54,6 +54,7 @@ if __name__ == '__main__':
gi.require_version('Gtk', '3.0')
gi.require_version('Gdk', '3.0')
gi.require_version('Wnck', '3.0')
gi.require_version('Handy', '0.0')
from gi.repository import Gio
......
......@@ -2,103 +2,53 @@
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkHeaderBar" id="headerbar">
<object class="GtkButton" id="applyButton">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="show_close_button">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_applyButton_clicked" swapped="no"/>
<child>
<object class="GtkButton" id="wallpapersFoldersBtn">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_wallpapersFoldersBtn_clicked" swapped="no"/>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">folder-symbolic</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkToggleButton" id="lowerAllOtherWindowsToggle">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Lower all other windows</property>
<signal name="toggled" handler="on_lowerAllOtherWindowsToggle_toggled" swapped="no"/>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">go-bottom-symbolic</property>
</object>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child type="title">
<object class="GtkStackSwitcher" id="mainStackSwitcher">
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="tooltip_text" translatable="yes">Apply</property>
<property name="icon_name">object-select-symbolic</property>
</object>
</child>
<style>
<class name="suggested-action"/>
</style>
</object>
<object class="GtkSpinner" id="applySpinner">
<property name="width_request">32</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<object class="GtkToggleButton" id="lowerAllOtherWindowsToggle">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Lower all other windows</property>
<signal name="toggled" handler="on_lowerAllOtherWindowsToggle_toggled" swapped="no"/>
<child>
<object class="GtkButton" id="applyButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_applyButton_clicked" swapped="no"/>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Apply</property>
<property name="icon_name">object-select-symbolic</property>
</object>
</child>
<style>
<class name="suggested-action"/>
</style>
</object>
<packing>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="menuBtn">
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_menuBtn_clicked" swapped="no"/>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">open-menu-symbolic</property>
</object>
</child>
<property name="can_focus">False</property>
<property name="icon_name">go-bottom-symbolic</property>
</object>
<packing>
<property name="pack_type">end</property>
<property name="position">2</property>
</packing>
</child>
</object>
<object class="GtkButton" id="menuBtn">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_menuBtn_clicked" swapped="no"/>
<child>
<object class="GtkSpinner" id="applySpinner">
<property name="width_request">32</property>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">open-menu-symbolic</property>
</object>
<packing>
<property name="pack_type">end</property>
<property name="position">3</property>
</packing>
</child>
</object>
<object class="GtkPopoverMenu" id="menuPopover">
......@@ -109,6 +59,19 @@
<placeholder/>
</child>
</object>
<object class="GtkButton" id="wallpapersFoldersBtn">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_wallpapersFoldersBtn_clicked" swapped="no"/>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">folder-symbolic</property>
</object>
</child>
</object>
<object class="GtkPopover" id="wallpapersFoldersPopover">
<property name="height_request">250</property>
<property name="can_focus">False</property>
......
from gi.repository import Gtk
from .confManager import ConfManager
from .wnck_win_controller import change_minimize_state
from .wallpapers_folders_view import HydraPaperWallpapersFoldersView
from .confManager import ConfManager
from .main_stack import HydraPapaerMainStack
from .monitors_flowbox import HydraPaperMonitorsFlowbox
from .apply_wallpapers import apply_wallpapers
from .headerbar import HydraPaperHeaderbar
class HydraPaperAppWindow(Gtk.ApplicationWindow):
def __init__(self, **kwargs):
......@@ -14,20 +14,10 @@ class HydraPaperAppWindow(Gtk.ApplicationWindow):
self.set_title('HydraPaper')
self.set_icon_name('org.gabmus.hydrapaper')
self.container_box = Gtk.Box(orientation = Gtk.Orientation.VERTICAL)
self.headerbar_builder = Gtk.Builder.new_from_resource(
'/org/gabmus/hydrapaper/ui/headerbar.glade'
)
self.headerbar = self.headerbar_builder.get_object('headerbar')
self.wallpapers_folders_popover = self.headerbar_builder.get_object(
'wallpapersFoldersPopover'
)
self.folders_view = HydraPaperWallpapersFoldersView(self)
self.wallpapers_folders_popover.add(self.folders_view)
self.apply_spinner = self.headerbar_builder.get_object('applySpinner')
self.stack_switcher = self.headerbar_builder.get_object(
'mainStackSwitcher'
)
self.headerbar = HydraPaperHeaderbar(self, self.apply_handler)
self.folders_view = self.headerbar.folders_view
self.apply_spinner = self.headerbar.apply_spinner
self.stack_switcher = self.headerbar.stack_switcher
self.main_stack = HydraPapaerMainStack()
self.stack_switcher.set_stack(self.main_stack)
self.monitors_flowbox = HydraPaperMonitorsFlowbox()
......@@ -38,7 +28,6 @@ class HydraPaperAppWindow(Gtk.ApplicationWindow):
self.container_box.pack_start(self.main_stack, True, True, 0)
self.add(self.container_box)
self.set_titlebar(self.headerbar)
self.headerbar_builder.connect_signals(self)
# self.connect('destroy', self.destroy)
self.resize(
self.confman.conf['windowsize']['width'],
......@@ -47,7 +36,7 @@ class HydraPaperAppWindow(Gtk.ApplicationWindow):
self.size_allocation = self.get_allocation()
self.connect('size-allocate', self.update_size_allocation)
self.menu_popover = self.headerbar_builder.get_object('menuPopover')
self.menu_popover = self.headerbar.menu_popover
self.menu_builder = Gtk.Builder.new_from_resource(
'/org/gabmus/hydrapaper/ui/menu.xml'
)
......@@ -81,7 +70,7 @@ class HydraPaperAppWindow(Gtk.ApplicationWindow):
super().show_all(**kwargs)
self.main_stack.main_flowbox.show_hide_wallpapers()
def on_applyButton_clicked(self, btn):
def apply_handler(self, btn):
apply_wallpapers(
monitors = self.monitors_flowbox.monitors,
widgets_to_freeze = [
......@@ -92,15 +81,6 @@ class HydraPaperAppWindow(Gtk.ApplicationWindow):
)
self.monitors_flowbox.dump_to_config()
def on_menuBtn_clicked(self, btn):
self.menu_popover.popup()
def on_wallpapersFoldersBtn_clicked(self, btn):
self.wallpapers_folders_popover.popup()
def on_lowerAllOtherWindowsToggle_toggled(self, toggle):
change_minimize_state(toggle = toggle)
def on_destroy(self, *args):
change_minimize_state(state = False)
self.confman.conf['windowsize'] = {
......
from gi.repository import Gtk, Handy
from .wnck_win_controller import change_minimize_state
from .wallpapers_folders_view import HydraPaperWallpapersFoldersView
class HydraPaperHeaderbar(Handy.HeaderBar):
def __init__(self, window, apply_handler, *args, **kwargs):
super().__init__(*args, **kwargs)
self.apply_handler = apply_handler
self.set_show_close_button(True)
self.stack_switcher = Handy.ViewSwitcher()
self.set_custom_title(self.stack_switcher)
self.folders_view = HydraPaperWallpapersFoldersView(window)
self.builder = Gtk.Builder.new_from_resource(
'/org/gabmus/hydrapaper/ui/headerbar.glade'
)
self.wallpapers_folders_popover = self.builder.get_object(
'wallpapersFoldersPopover'
)
self.wallpapers_folders_popover.add(self.folders_view)
self.menu_popover = self.builder.get_object('menuPopover')
self.apply_spinner = self.builder.get_object('applySpinner')
self.apply_button = self.builder.get_object('applyButton')
self.lower_windows_toggle = self.builder.get_object(
'lowerAllOtherWindowsToggle'
)
self.menu_button = self.builder.get_object('menuBtn')
self.wallpapers_folders_button = self.builder.get_object(
'wallpapersFoldersBtn'
)
left_widgets = [
self.wallpapers_folders_button,
self.lower_windows_toggle
]
right_widgets = [
self.apply_button,
self.menu_button,
self.apply_spinner
]
for w in left_widgets:
self.pack_start(w)
for w in right_widgets:
self.pack_end(w)
self.builder.connect_signals(self)
def on_menuBtn_clicked(self, btn):
self.menu_popover.popup()
def on_wallpapersFoldersBtn_clicked(self, btn):
self.wallpapers_folders_popover.popup()
def on_lowerAllOtherWindowsToggle_toggled(self, toggle):
change_minimize_state(toggle = toggle)
def on_applyButton_clicked(self, btn):
self.apply_handler(btn)
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