replace toggle item for connection with GtkSwitch
This commit is contained in:
parent
27f84b683a
commit
7509a0d672
2 changed files with 26 additions and 9 deletions
|
|
@ -646,17 +646,26 @@
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="show_close_button">True</property>
|
<property name="show_close_button">True</property>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkToolbar">
|
<object class="GtkToolbar">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="show_arrow">False</property>
|
<property name="show_arrow">False</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkToggleToolButton" id="headerbar-connect">
|
<object class="GtkToolItem">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="icon_name">gtk-disconnect</property>
|
<child>
|
||||||
<signal name="toggled" handler="on_headerbar-connect_toggled" swapped="no"/>
|
<object class="GtkSwitch" id="headerbar-connection">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<signal name="notify::active" handler="on_headerbar-connection_active_notify" swapped="no"/>
|
||||||
|
<signal name="state-set" handler="on_headerbar-connection_state_set" swapped="no"/>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
|
|
@ -690,6 +699,9 @@
|
||||||
<class name="no-bg"/>
|
<class name="no-bg"/>
|
||||||
</style>
|
</style>
|
||||||
</object>
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="position">1</property>
|
||||||
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child type="title">
|
<child type="title">
|
||||||
<object class="GtkStackSwitcher" id="header-panelswitcher">
|
<object class="GtkStackSwitcher" id="header-panelswitcher">
|
||||||
|
|
|
||||||
|
|
@ -426,7 +426,7 @@ class Window():
|
||||||
|
|
||||||
class HeaderBar(mcg.Base):
|
class HeaderBar(mcg.Base):
|
||||||
SIGNAL_STACK_SWITCHED = 'stack-switched'
|
SIGNAL_STACK_SWITCHED = 'stack-switched'
|
||||||
SIGNAL_CONNECT = 'on_headerbar-connect_toggled'
|
SIGNAL_CONNECT = 'on_headerbar-connection_active_notify'
|
||||||
SIGNAL_PLAYPAUSE = 'on_headerbar-playpause_toggled'
|
SIGNAL_PLAYPAUSE = 'on_headerbar-playpause_toggled'
|
||||||
SIGNAL_SET_VOLUME = 'set-volume'
|
SIGNAL_SET_VOLUME = 'set-volume'
|
||||||
|
|
||||||
|
|
@ -441,14 +441,15 @@ class HeaderBar(mcg.Base):
|
||||||
# Widgets
|
# Widgets
|
||||||
self._header_bar = builder.get_object('headerbar')
|
self._header_bar = builder.get_object('headerbar')
|
||||||
self._stack_switcher = StackSwitcher(builder)
|
self._stack_switcher = StackSwitcher(builder)
|
||||||
self._buttons[HeaderBar.SIGNAL_CONNECT] = builder.get_object('headerbar-connect')
|
self._buttons[HeaderBar.SIGNAL_CONNECT] = builder.get_object('headerbar-connection')
|
||||||
self._buttons[HeaderBar.SIGNAL_PLAYPAUSE] = builder.get_object('headerbar-playpause')
|
self._buttons[HeaderBar.SIGNAL_PLAYPAUSE] = builder.get_object('headerbar-playpause')
|
||||||
self._buttons[HeaderBar.SIGNAL_SET_VOLUME] = builder.get_object('headerbar-volume')
|
self._buttons[HeaderBar.SIGNAL_SET_VOLUME] = builder.get_object('headerbar-volume')
|
||||||
|
|
||||||
# Signals
|
# Signals
|
||||||
self._stack_switcher.connect_signal(StackSwitcher.SIGNAL_STACK_SWITCHED, self.on_stack_switched)
|
self._stack_switcher.connect_signal(StackSwitcher.SIGNAL_STACK_SWITCHED, self.on_stack_switched)
|
||||||
self._button_handlers = {
|
self._button_handlers = {
|
||||||
'on_headerbar-connect_toggled': self._callback_from_widget,
|
'on_headerbar-connection_active_notify': self._callback_from_widget,
|
||||||
|
'on_headerbar-connection_state_set': self.on_connection_state_set,
|
||||||
'on_headerbar-playpause_toggled': self._callback_from_widget,
|
'on_headerbar-playpause_toggled': self._callback_from_widget,
|
||||||
'on_headerbar-volume_value_changed': self.on_volume_changed,
|
'on_headerbar-volume_value_changed': self.on_volume_changed,
|
||||||
'on_headerbar-volume_button_press_event': self.on_volume_press,
|
'on_headerbar-volume_button_press_event': self.on_volume_press,
|
||||||
|
|
@ -471,6 +472,10 @@ class HeaderBar(mcg.Base):
|
||||||
self._buttons[HeaderBar.SIGNAL_CONNECT].set_sensitive(not connecting)
|
self._buttons[HeaderBar.SIGNAL_CONNECT].set_sensitive(not connecting)
|
||||||
|
|
||||||
|
|
||||||
|
def on_connection_state_set(self, widget, state):
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def on_stack_switched(self, widget):
|
def on_stack_switched(self, widget):
|
||||||
self._callback(HeaderBar.SIGNAL_STACK_SWITCHED, widget)
|
self._callback(HeaderBar.SIGNAL_STACK_SWITCHED, widget)
|
||||||
|
|
||||||
|
|
@ -496,8 +501,8 @@ class HeaderBar(mcg.Base):
|
||||||
self._buttons[HeaderBar.SIGNAL_CONNECT].handler_block_by_func(
|
self._buttons[HeaderBar.SIGNAL_CONNECT].handler_block_by_func(
|
||||||
self._button_handlers[HeaderBar.SIGNAL_CONNECT]
|
self._button_handlers[HeaderBar.SIGNAL_CONNECT]
|
||||||
)
|
)
|
||||||
self._buttons[HeaderBar.SIGNAL_CONNECT].set_stock_id(Gtk.STOCK_CONNECT)
|
|
||||||
self._buttons[HeaderBar.SIGNAL_CONNECT].set_active(True)
|
self._buttons[HeaderBar.SIGNAL_CONNECT].set_active(True)
|
||||||
|
self._buttons[HeaderBar.SIGNAL_CONNECT].set_state(True)
|
||||||
self._buttons[HeaderBar.SIGNAL_CONNECT].handler_unblock_by_func(
|
self._buttons[HeaderBar.SIGNAL_CONNECT].handler_unblock_by_func(
|
||||||
self._button_handlers[HeaderBar.SIGNAL_CONNECT]
|
self._button_handlers[HeaderBar.SIGNAL_CONNECT]
|
||||||
)
|
)
|
||||||
|
|
@ -507,8 +512,8 @@ class HeaderBar(mcg.Base):
|
||||||
self._buttons[HeaderBar.SIGNAL_CONNECT].handler_block_by_func(
|
self._buttons[HeaderBar.SIGNAL_CONNECT].handler_block_by_func(
|
||||||
self._button_handlers[HeaderBar.SIGNAL_CONNECT]
|
self._button_handlers[HeaderBar.SIGNAL_CONNECT]
|
||||||
)
|
)
|
||||||
self._buttons[HeaderBar.SIGNAL_CONNECT].set_stock_id(Gtk.STOCK_DISCONNECT)
|
|
||||||
self._buttons[HeaderBar.SIGNAL_CONNECT].set_active(False)
|
self._buttons[HeaderBar.SIGNAL_CONNECT].set_active(False)
|
||||||
|
self._buttons[HeaderBar.SIGNAL_CONNECT].set_state(False)
|
||||||
self._buttons[HeaderBar.SIGNAL_CONNECT].handler_unblock_by_func(
|
self._buttons[HeaderBar.SIGNAL_CONNECT].handler_unblock_by_func(
|
||||||
self._button_handlers[HeaderBar.SIGNAL_CONNECT]
|
self._button_handlers[HeaderBar.SIGNAL_CONNECT]
|
||||||
)
|
)
|
||||||
|
|
@ -545,7 +550,7 @@ class HeaderBar(mcg.Base):
|
||||||
self._buttons[HeaderBar.SIGNAL_SET_VOLUME].set_visible(False)
|
self._buttons[HeaderBar.SIGNAL_SET_VOLUME].set_visible(False)
|
||||||
|
|
||||||
|
|
||||||
def _callback_from_widget(self, widget):
|
def _callback_from_widget(self, widget, *args):
|
||||||
if widget is self._buttons[HeaderBar.SIGNAL_CONNECT]:
|
if widget is self._buttons[HeaderBar.SIGNAL_CONNECT]:
|
||||||
self._callback(self.SIGNAL_CONNECT)
|
self._callback(self.SIGNAL_CONNECT)
|
||||||
elif widget is self._buttons[HeaderBar.SIGNAL_PLAYPAUSE]:
|
elif widget is self._buttons[HeaderBar.SIGNAL_PLAYPAUSE]:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue