Back to index

unity  6.0.0
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Private Member Functions | Private Attributes
unity::LauncherEntryRemote Class Reference

Instances of this class mirrors the remote metadata for a laucnher entry exposed by an application via the com.canonical.Unity.LauncherEntry DBus API. More...

#include <LauncherEntryRemote.h>

Inheritance diagram for unity::LauncherEntryRemote:
Inheritance graph
[legend]
Collaboration diagram for unity::LauncherEntryRemote:
Collaboration graph
[legend]

List of all members.

Public Types

typedef std::shared_ptr
< LauncherEntryRemote
Ptr
typedef std::list
< Introspectable * > 
IntrospectableList

Public Member Functions

 LauncherEntryRemote (std::string const &dbus_name, GVariant *val)
 Create a new LauncherEntryRemote parsed from the raw DBus wire format of the com.canonical.Unity.LauncherEntry.Update signal '(sa{sv})'.
std::string const & AppUri () const
 The appuri property is on the form application://$desktop_file_id and is used within the LauncherEntryRemoteModel to uniquely identify the various applications.
std::string const & DBusName () const
 Return the unique DBus name for the remote party owning this launcher entry.
std::string const & Emblem () const
long long Count () const
double Progress () const
glib::Object< DbusmenuClient >
const & 
Quicklist () const
 Return a pointer to the current quicklist of the launcher entry; NULL if it's unset.
bool EmblemVisible () const
bool CountVisible () const
bool ProgressVisible () const
bool Urgent () const
void Update (LauncherEntryRemote::Ptr const &other)
 Update this instance using details from another:
void Update (GVariantIter *prop_iter)
 Update this instance from a GVariant property iterator.
void SetDBusName (std::string const &dbus_name)
 Set a new DBus name. This destroys the current quicklist.
std::string GetName () const
void AddProperties (GVariantBuilder *builder)
GVariant * Introspect ()
void AddChild (Introspectable *child)
void RemoveChild (Introspectable *child)
virtual IntrospectableList GetIntrospectableChildren ()
guint64 GetIntrospectionId () const

Public Attributes

sigc::signal< void,
LauncherEntryRemote
*, std::string > 
dbus_name_changed
sigc::signal< void,
LauncherEntryRemote * > 
emblem_changed
sigc::signal< void,
LauncherEntryRemote * > 
count_changed
sigc::signal< void,
LauncherEntryRemote * > 
progress_changed
sigc::signal< void,
LauncherEntryRemote * > 
quicklist_changed
sigc::signal< void,
LauncherEntryRemote * > 
emblem_visible_changed
sigc::signal< void,
LauncherEntryRemote * > 
count_visible_changed
sigc::signal< void,
LauncherEntryRemote * > 
progress_visible_changed
sigc::signal< void,
LauncherEntryRemote * > 
urgent_changed

Protected Member Functions

virtual std::string GetChildsName () const
 Please don't override this unless you really need to. The only valid reason is if you have a property that simply must be called 'Children'.

Private Member Functions

void SetEmblem (std::string const &emblem)
void SetCount (long long count)
void SetProgress (double progress)
void SetQuicklistPath (std::string const &dbus_path)
 Set the quicklist of this entry to be the Dbusmenu on the given path.
void SetQuicklist (DbusmenuClient *quicklist)
 Set the quicklist of this entry to a given DbusmenuClient.
void SetEmblemVisible (bool visible)
void SetCountVisible (bool visible)
void SetProgressVisible (bool visible)
void SetUrgent (bool urgent)

Private Attributes

std::string _dbus_name
std::string _app_uri
std::string _emblem
long long _count
double _progress
std::string _quicklist_dbus_path
glib::Object< DbusmenuClient > _quicklist
bool _emblem_visible
bool _count_visible
bool _progress_visible
bool _urgent

Detailed Description

Instances of this class mirrors the remote metadata for a laucnher entry exposed by an application via the com.canonical.Unity.LauncherEntry DBus API.

You do not create instances of LauncherEntryRemote yourself. Instead they are created and managed dynamically by a LauncherEntryRemoteModel.

Definition at line 42 of file LauncherEntryRemote.h.


Member Typedef Documentation

Definition at line 34 of file Introspectable.h.

Definition at line 45 of file LauncherEntryRemote.h.


Constructor & Destructor Documentation

unity::LauncherEntryRemote::LauncherEntryRemote ( std::string const &  dbus_name,
GVariant *  val 
)

Create a new LauncherEntryRemote parsed from the raw DBus wire format of the com.canonical.Unity.LauncherEntry.Update signal '(sa{sv})'.

The dbus_name argument should be the unique bus name of the process owning the launcher entry.

You don't normally need to use this constructor yourself. The LauncherEntryRemoteModel will do that for you when needed.

Definition at line 42 of file LauncherEntryRemote.cpp.

  : _dbus_name(dbus_name)
  , _count(0)
  , _progress(0.0f)
  , _emblem_visible(false)
  , _count_visible(false)
  , _progress_visible(false)
  , _urgent(false)
{
  glib::String app_uri;
  GVariantIter* prop_iter;

  if (!val || dbus_name.empty())
  {
    LOG_ERROR(logger) << "Invalid launcher entry remote construction";
    return;
  }

  /* This will make sure that the values are properly ref_sink'ed and unreff'ed */
  glib::Variant values(val);
  g_variant_get(values, "(sa{sv})", &app_uri, &prop_iter);

  _app_uri = app_uri.Str();

  Update(prop_iter);
  g_variant_iter_free(prop_iter);
}

Here is the call graph for this function:


Member Function Documentation

Definition at line 78 of file Introspectable.cpp.

{
  _children.push_back(child);
  child->_parents.push_back(this);
}

Here is the caller graph for this function:

void unity::LauncherEntryRemote::AddProperties ( GVariantBuilder *  builder) [virtual]

Implements unity::debug::Introspectable.

Definition at line 365 of file LauncherEntryRemote.cpp.

{
  variant::BuilderWrapper(builder)
    .add("count", Count())
    .add("progress", Progress())
    .add("emblem_visible", EmblemVisible())
    .add("count_visible", CountVisible())
    .add("progress_visible", ProgressVisible())
    .add("urgent", Urgent());
}

Here is the call graph for this function:

std::string const & unity::LauncherEntryRemote::AppUri ( ) const

The appuri property is on the form application://$desktop_file_id and is used within the LauncherEntryRemoteModel to uniquely identify the various applications.

Note that a desktop file id is defined to be the base name of the desktop file including the extension. Eg. gedit.desktop. Thus a full appuri could be application://gedit.desktop.

Definition at line 79 of file LauncherEntryRemote.cpp.

{
  return _app_uri;
}
long long unity::LauncherEntryRemote::Count ( ) const

Definition at line 97 of file LauncherEntryRemote.cpp.

{
  return _count;
}

Here is the caller graph for this function:

Definition at line 123 of file LauncherEntryRemote.cpp.

{
  return _count_visible;
}

Here is the caller graph for this function:

std::string const & unity::LauncherEntryRemote::DBusName ( ) const

Return the unique DBus name for the remote party owning this launcher entry.

Definition at line 87 of file LauncherEntryRemote.cpp.

{
  return _dbus_name;
}
std::string const & unity::LauncherEntryRemote::Emblem ( ) const

Definition at line 92 of file LauncherEntryRemote.cpp.

{
  return _emblem;
}

Here is the caller graph for this function:

Definition at line 118 of file LauncherEntryRemote.cpp.

{
  return _emblem_visible;
}

Here is the caller graph for this function:

std::string unity::debug::Introspectable::GetChildsName ( ) const [protected, virtual, inherited]

Please don't override this unless you really need to. The only valid reason is if you have a property that simply must be called 'Children'.

Definition at line 92 of file Introspectable.cpp.

{
  return "Children";
}

Here is the caller graph for this function:

Introspectable::IntrospectableList unity::debug::Introspectable::GetIntrospectableChildren ( ) [virtual, inherited]

Reimplemented in unity::hud::View, unity::launcher::LauncherModel, unity::QuicklistView, and unity::dash::ResultView.

Definition at line 41 of file Introspectable.cpp.

{
  return _children;
}

Here is the caller graph for this function:

guint64 unity::debug::Introspectable::GetIntrospectionId ( ) const [inherited]

Definition at line 97 of file Introspectable.cpp.

{
  return _id;
}

Here is the caller graph for this function:

std::string unity::LauncherEntryRemote::GetName ( ) const [virtual]

Implements unity::debug::Introspectable.

Definition at line 359 of file LauncherEntryRemote.cpp.

{
  // This seems a more appropriate name than LauncherEntryRemote
  return "LauncherEntry";
}
GVariant * unity::debug::Introspectable::Introspect ( ) [inherited]

Definition at line 47 of file Introspectable.cpp.

{
  GVariantBuilder  builder;
  GVariantBuilder  child_builder;
  gint             n_children = 0;

  g_variant_builder_init(&builder, G_VARIANT_TYPE("a{sv}"));
  g_variant_builder_add(&builder, "{sv}", "id", g_variant_new_uint64(_id));

  AddProperties(&builder);

  g_variant_builder_init(&child_builder, G_VARIANT_TYPE("as"));

  auto children = GetIntrospectableChildren();
  for (auto it = children.begin(); it != children.end(); it++)
  {
    if ((*it)->GetName() != "")
    {
      g_variant_builder_add(&child_builder, "s", (*it)->GetName().c_str());
      n_children++;
    }
  }

  GVariant* child_results = g_variant_builder_end(&child_builder);

  if (n_children > 0)
    g_variant_builder_add(&builder, "{sv}", GetChildsName().c_str(), child_results);
  return g_variant_builder_end(&builder);
}

Here is the call graph for this function:

Definition at line 102 of file LauncherEntryRemote.cpp.

{
  return _progress;
}

Here is the caller graph for this function:

Definition at line 128 of file LauncherEntryRemote.cpp.

{
  return _progress_visible;
}

Here is the caller graph for this function:

glib::Object< DbusmenuClient > const & unity::LauncherEntryRemote::Quicklist ( ) const

Return a pointer to the current quicklist of the launcher entry; NULL if it's unset.

The returned object should not be freed.

Definition at line 113 of file LauncherEntryRemote.cpp.

{
  return _quicklist;
}

Here is the caller graph for this function:

Definition at line 85 of file Introspectable.cpp.

{
  _children.remove(child);
  child->_parents.remove(this);
}

Here is the caller graph for this function:

void unity::LauncherEntryRemote::SetCount ( long long  count) [private]

Definition at line 168 of file LauncherEntryRemote.cpp.

{
  if (_count == count)
    return;

  _count = count;
  count_changed.emit(this);
}

Here is the caller graph for this function:

void unity::LauncherEntryRemote::SetCountVisible ( bool  visible) [private]

Definition at line 273 of file LauncherEntryRemote.cpp.

{
  if (_count_visible == visible)
    return;

  _count_visible = visible;
  count_visible_changed.emit(this);
}

Here is the caller graph for this function:

void unity::LauncherEntryRemote::SetDBusName ( std::string const &  dbus_name)

Set a new DBus name. This destroys the current quicklist.

Set the unique DBus name for the process owning the launcher entry.

If the entry has any exported quicklist it will be removed.

Definition at line 143 of file LauncherEntryRemote.cpp.

{
  if (_dbus_name == dbus_name)
    return;

  std::string old_name(_dbus_name);
  _dbus_name = dbus_name;

  /* Remove the quicklist since we can't know if it it'll be valid on the
   * new name, and we certainly don't want the quicklist to operate on a
   * different name than the rest of the launcher API */
  SetQuicklist(nullptr);

  dbus_name_changed.emit(this, old_name);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void unity::LauncherEntryRemote::SetEmblem ( std::string const &  emblem) [private]

Definition at line 159 of file LauncherEntryRemote.cpp.

{
  if (_emblem == emblem)
    return;

  _emblem = emblem;
  emblem_changed.emit(this);
}

Here is the caller graph for this function:

void unity::LauncherEntryRemote::SetEmblemVisible ( bool  visible) [private]

Definition at line 264 of file LauncherEntryRemote.cpp.

{
  if (_emblem_visible == visible)
    return;

  _emblem_visible = visible;
  emblem_visible_changed.emit(this);
}

Here is the caller graph for this function:

void unity::LauncherEntryRemote::SetProgress ( double  progress) [private]

Definition at line 177 of file LauncherEntryRemote.cpp.

{
  if (_progress == progress)
    return;

  _progress = progress;
  progress_changed.emit(this);
}

Here is the caller graph for this function:

void unity::LauncherEntryRemote::SetProgressVisible ( bool  visible) [private]

Definition at line 282 of file LauncherEntryRemote.cpp.

{
  if (_progress_visible == visible)
    return;

  _progress_visible = visible;
  progress_visible_changed.emit(this);
}

Here is the caller graph for this function:

void unity::LauncherEntryRemote::SetQuicklist ( DbusmenuClient *  quicklist) [private]

Set the quicklist of this entry to a given DbusmenuClient.

If entry already has a quicklist with the same path this call is a no-op.

To unset the quicklist for this entry pass in NULL as the quicklist to set.

Definition at line 224 of file LauncherEntryRemote.cpp.

{
  /* Check if existing quicklist have exact same path as the new one
   * and ignore the change in that case. We also assert that the quicklist
   * uses the same name as the connection owning this launcher entry */
  if (_quicklist)
  {
    glib::String ql_path, new_ql_path, new_ql_name;

    g_object_get(_quicklist, DBUSMENU_CLIENT_PROP_DBUS_OBJECT, &ql_path, NULL);

    if (quicklist)
    {
      g_object_get(quicklist, DBUSMENU_CLIENT_PROP_DBUS_OBJECT, &new_ql_path, NULL);
      g_object_get(quicklist, DBUSMENU_CLIENT_PROP_DBUS_NAME, &new_ql_name, NULL);
    }

    if (quicklist && new_ql_name.Str() != _dbus_name)
    {
      LOG_ERROR(logger) << "Mismatch between quicklist- and launcher entry owner:"
                        << new_ql_name << " and " << _dbus_name << " respectively";
      return;
    }

    if (new_ql_path.Str() == ql_path.Str())
    {
      return;
    }
  }
  else if (!_quicklist && !quicklist)
    return;

  if (!quicklist)
    _quicklist = nullptr;
  else
    _quicklist = glib::Object<DbusmenuClient>(quicklist, glib::AddRef());

  quicklist_changed.emit(this);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void unity::LauncherEntryRemote::SetQuicklistPath ( std::string const &  dbus_path) [private]

Set the quicklist of this entry to be the Dbusmenu on the given path.

If entry already has a quicklist with the same path this call is a no-op.

To unset the quicklist pass in a NULL path or empty string.

Definition at line 192 of file LauncherEntryRemote.cpp.

{
  /* Check if existing quicklist have exact same path
   * and ignore the change in that case */
  if (_quicklist)
  {
    glib::String ql_path;
    g_object_get(_quicklist, DBUSMENU_CLIENT_PROP_DBUS_OBJECT, &ql_path, NULL);

    if (ql_path.Str() == dbus_path)
    {
      return;
    }
  }
  else if (!_quicklist && dbus_path.empty())
    return;

  if (!dbus_path.empty())
    _quicklist = dbusmenu_client_new(_dbus_name.c_str(), dbus_path.c_str());
  else
    _quicklist = nullptr;

  quicklist_changed.emit(this);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void unity::LauncherEntryRemote::SetUrgent ( bool  urgent) [private]

Definition at line 291 of file LauncherEntryRemote.cpp.

{
  if (_urgent == urgent)
    return;

  _urgent = urgent;
  urgent_changed.emit(this);
}

Here is the caller graph for this function:

Update this instance using details from another:

Set all properties from 'other' on 'this'.

Definition at line 303 of file LauncherEntryRemote.cpp.

{
  /* It's important that we update the DBus name first since it might
   * unset the quicklist if it changes */

  if (!other)
    return;

  SetDBusName(other->DBusName());

  SetEmblem(other->Emblem());
  SetCount(other->Count());
  SetProgress(other->Progress());
  SetQuicklist(other->Quicklist());
  SetUrgent(other->Urgent());

  SetEmblemVisible(other->EmblemVisible());
  SetCountVisible(other->CountVisible());
  SetProgressVisible(other->ProgressVisible());
}

Here is the call graph for this function:

Here is the caller graph for this function:

void unity::LauncherEntryRemote::Update ( GVariantIter *  prop_iter)

Update this instance from a GVariant property iterator.

Iterate over a GVariantIter containing elements of type '{sv}' and apply any properties to 'this'.

Definition at line 328 of file LauncherEntryRemote.cpp.

{
  gchar* prop_key;
  GVariant* prop_value;

  g_return_if_fail(prop_iter != NULL);

  while (g_variant_iter_loop(prop_iter, "{sv}", &prop_key, &prop_value))
  {
    if (g_str_equal("emblem", prop_key))
      SetEmblem(glib::String(g_variant_dup_string(prop_value, 0)).Str());
    else if (g_str_equal("count", prop_key))
      SetCount(g_variant_get_int64(prop_value));
    else if (g_str_equal("progress", prop_key))
      SetProgress(g_variant_get_double(prop_value));
    else if (g_str_equal("emblem-visible", prop_key))
      SetEmblemVisible(g_variant_get_boolean(prop_value));
    else if (g_str_equal("count-visible", prop_key))
      SetCountVisible(g_variant_get_boolean(prop_value));
    else if (g_str_equal("progress-visible", prop_key))
      SetProgressVisible(g_variant_get_boolean(prop_value));
    else if (g_str_equal("urgent", prop_key))
      SetUrgent(g_variant_get_boolean(prop_value));
    else if (g_str_equal("quicklist", prop_key))
    {
      /* The value is the object path of the dbusmenu */
      SetQuicklistPath(glib::String(g_variant_dup_string(prop_value, 0)).Str());
    }
  }
}

Here is the call graph for this function:

Definition at line 133 of file LauncherEntryRemote.cpp.

{
  return _urgent;
}

Here is the caller graph for this function:


Member Data Documentation

std::string unity::LauncherEntryRemote::_app_uri [private]

Definition at line 86 of file LauncherEntryRemote.h.

Definition at line 88 of file LauncherEntryRemote.h.

Definition at line 95 of file LauncherEntryRemote.h.

Definition at line 84 of file LauncherEntryRemote.h.

std::string unity::LauncherEntryRemote::_emblem [private]

Definition at line 87 of file LauncherEntryRemote.h.

Definition at line 94 of file LauncherEntryRemote.h.

Definition at line 89 of file LauncherEntryRemote.h.

Definition at line 96 of file LauncherEntryRemote.h.

Definition at line 92 of file LauncherEntryRemote.h.

Definition at line 91 of file LauncherEntryRemote.h.

Definition at line 97 of file LauncherEntryRemote.h.

Definition at line 74 of file LauncherEntryRemote.h.

Definition at line 79 of file LauncherEntryRemote.h.

Definition at line 72 of file LauncherEntryRemote.h.

Definition at line 73 of file LauncherEntryRemote.h.

Definition at line 78 of file LauncherEntryRemote.h.

Definition at line 75 of file LauncherEntryRemote.h.

Definition at line 80 of file LauncherEntryRemote.h.

Definition at line 76 of file LauncherEntryRemote.h.

Definition at line 81 of file LauncherEntryRemote.h.


The documentation for this class was generated from the following files: