Fix no action button icon #296
This commit is contained in:
parent
21cf1df3d3
commit
2119b62c81
|
@ -139,9 +139,9 @@ class BreakScreen(object):
|
|||
def __tray_action(self, button, tray_action):
|
||||
"""
|
||||
Tray action handler.
|
||||
Hides the toolbar button and call the action provided by the plugin.
|
||||
Hides all toolbar buttons for this action and call the action provided by the plugin.
|
||||
"""
|
||||
button.hide()
|
||||
tray_action.reset()
|
||||
tray_action.action()
|
||||
|
||||
def __show_break_screen(self, message, image_path, widget, tray_actions):
|
||||
|
@ -174,10 +174,11 @@ class BreakScreen(object):
|
|||
|
||||
for tray_action in tray_actions:
|
||||
toolbar_button = None
|
||||
if isinstance(tray_action.icon, str):
|
||||
toolbar_button = Gtk.ToolButton.new_from_stock(tray_action.icon)
|
||||
if tray_action.system_icon:
|
||||
toolbar_button = Gtk.ToolButton.new_from_stock(tray_action.get_icon())
|
||||
else:
|
||||
toolbar_button = Gtk.ToolButton.new(tray_action.icon, tray_action.name)
|
||||
toolbar_button = Gtk.ToolButton.new(tray_action.get_icon(), tray_action.name)
|
||||
tray_action.add_toolbar_button(toolbar_button)
|
||||
toolbar_button.connect("clicked", lambda button, action: self.__tray_action(button, action), tray_action)
|
||||
toolbar_button.set_tooltip_text(_(tray_action.name))
|
||||
toolbar.add(toolbar_button)
|
||||
|
@ -216,7 +217,6 @@ class BreakScreen(object):
|
|||
window.set_opacity(0.9)
|
||||
|
||||
# In Unity, move the window before present
|
||||
# if self.context['desktop'] == 'unity':
|
||||
window.move(x, y)
|
||||
window.stick()
|
||||
window.set_keep_above(True)
|
||||
|
@ -224,6 +224,7 @@ class BreakScreen(object):
|
|||
# In other desktop environments, move the window after present
|
||||
# if self.context['desktop'] != 'unity':
|
||||
window.move(x, y)
|
||||
window.resize(monitor_gemoetry.width, monitor_gemoetry.height)
|
||||
logging.info("Moved break screen to Display[%d, %d]", x, y)
|
||||
window.fullscreen()
|
||||
|
||||
|
|
|
@ -304,16 +304,33 @@ class TrayAction(object):
|
|||
Data object wrapping name, icon and action.
|
||||
"""
|
||||
|
||||
def __init__(self, name, icon, action):
|
||||
def __init__(self, name, icon, action, system_icon):
|
||||
self.name = name
|
||||
self.icon = icon
|
||||
self.__icon = icon
|
||||
self.action = action
|
||||
self.system_icon = system_icon
|
||||
self.__toolbar_buttons = []
|
||||
|
||||
def get_icon(self):
|
||||
if self.system_icon:
|
||||
return self.__icon
|
||||
else:
|
||||
image = Utility.load_and_scale_image(self.__icon, 16, 16)
|
||||
image.show()
|
||||
return image
|
||||
|
||||
def add_toolbar_button(self, button):
|
||||
self.__toolbar_buttons.append(button)
|
||||
|
||||
def reset(self):
|
||||
for button in self.__toolbar_buttons:
|
||||
button.hide()
|
||||
self.__toolbar_buttons.clear()
|
||||
|
||||
@classmethod
|
||||
def build(cls, name, icon_path, icon_id, action):
|
||||
image = Utility.load_and_scale_image(icon_path, 12, 12)
|
||||
if image is None:
|
||||
return TrayAction(name, icon_id, action)
|
||||
return TrayAction(name, icon_id, action, True)
|
||||
else:
|
||||
image.show()
|
||||
return TrayAction(name, image, action)
|
||||
return TrayAction(name, icon_path, action, False)
|
||||
|
|
Loading…
Reference in New Issue