310
310
`icon` must be an instance of SimpleLauncherIcon or it's descendants.
312
312
if not isinstance(icon, SimpleLauncherIcon):
313
raise TypeError("icon must be a LauncherIcon")
313
raise TypeError("icon must be a LauncherIcon, not %s" % type(icon))
315
315
logger.debug("Clicking launcher icon %r on monitor %d with mouse button %d",
316
316
icon, self.monitor, button)
461
def get_icon_by_tooltip_text(self, tooltip_text):
462
"""Get a launcher icon given it's tooltip text.
464
Returns None if there is no icon with the specified text.
466
for icon in self.get_launcher_icons():
467
if icon.tooltip_text == tooltip_text:
471
def get_icon_by_desktop_id(self, desktop_id):
472
"""Gets a launcher icon with the specified desktop id.
474
Returns None if there is no such launcher icon.
476
icons = self.get_children_by_type(SimpleLauncherIcon, desktop_id=desktop_id)
482
def get_icon_by_window_xid(self, xid):
483
"""Gets a launcher icon that controls the specified window xid."""
484
icons = [i for i in self.get_children_by_type(SimpleLauncherIcon) if i.xids.contains(xid)]
490
def get_icons_by_filter(self, **kwargs):
491
"""Get a list of icons that satisfy the given filters.
495
>>> get_icons_by_filter(tooltip_text="My Application")
498
Returns an empty list if no icons matched the filter.
501
return self.get_children_by_type(SimpleLauncherIcon, **kwargs)
461
def get_icon(self, **kwargs):
462
"""Get a launcher icon from the model according to some filters.
464
This method accepts keyword argument that are the filters to use when
465
looking for an icon. For example, to find an icon with a particular
466
desktop_id, one might do this from within a test:
468
>>> self.launcher.model.get_icon(desktop_id="gcalctool.desktop")
470
This method returns only one icon. It is the callers responsibility to
471
ensure that the filter matches only one icon.
473
This method will attempt to get the launcher icon, and will retry several
474
times, so the caller can be assured that if this method doesn't find
475
the icon it really does not exist.
477
If no keyword arguments are specified, ValueError will be raised.
479
If no icons are matched, None is returned.
484
raise ValueError("You must specify at least one keyword argument to ths method.")
487
icons = self.get_children_by_type(SimpleLauncherIcon, **kwargs)
489
logger.warning("Got more than one icon returned using filters=%r. Returning first one", kwargs)
503
495
def num_launcher_icons(self):
504
496
"""Get the number of icons in the launcher model."""