Back to index

bamf  0.2.120
Classes | Defines | Typedefs | Functions
bamf-view.h File Reference
#include "bamf.h"
#include <glib.h>
#include <glib-object.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _BamfViewClass
struct  _BamfView

Defines

#define BAMF_TYPE_VIEW   (bamf_view_get_type ())
#define BAMF_VIEW(obj)   (G_TYPE_CHECK_INSTANCE_CAST ((obj), BAMF_TYPE_VIEW, BamfView))
#define BAMF_IS_VIEW(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BAMF_TYPE_VIEW))
#define BAMF_VIEW_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), BAMF_TYPE_VIEW, BamfViewClass))
#define BAMF_IS_VIEW_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), BAMF_TYPE_VIEW))
#define BAMF_VIEW_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), BAMF_TYPE_VIEW, BamfViewClass))

Typedefs

typedef struct _BamfView
typedef struct _BamfViewClass
typedef struct _BamfViewPrivate

Functions

GType bamf_view_get_type (void) G_GNUC_CONST
void bamf_view_close (BamfView *view)
GVariant * bamf_view_get_children_paths (BamfView *view)
GList * bamf_view_get_children (BamfView *view)
 bamf_view_get_children: : a #BamfView
GVariant * bamf_view_get_parent_paths (BamfView *view)
GList * bamf_view_get_parents (BamfView *view)
const char * bamf_view_get_path (BamfView *view)
void bamf_view_add_child (BamfView *view, BamfView *child)
void bamf_view_remove_child (BamfView *view, BamfView *child)
gboolean bamf_view_is_active (BamfView *view)
 bamf_view_is_active: : a #BamfView
void bamf_view_set_active (BamfView *view, gboolean active)
gboolean bamf_view_is_running (BamfView *view)
 bamf_view_is_running: : a #BamfView
void bamf_view_set_running (BamfView *view, gboolean running)
gboolean bamf_view_user_visible (BamfView *view)
 bamf_view_user_visible: : a #BamfView
void bamf_view_set_user_visible (BamfView *view, gboolean user_visible)
gboolean bamf_view_is_urgent (BamfView *view)
 bamf_view_is_running: : a #BamfView
void bamf_view_set_urgent (BamfView *view, gboolean urgent)
const char * bamf_view_get_icon (BamfView *view)
 bamf_view_get_icon: : a #BamfView
const char * bamf_view_get_name (BamfView *view)
 bamf_view_get_name: : a #BamfView
void bamf_view_set_name (BamfView *view, const char *name)
const char * bamf_view_get_parent_path (BamfView *view)
BamfView * bamf_view_get_parent (BamfView *view)
void bamf_view_set_parent (BamfView *view, BamfView *parent)
const char * bamf_view_get_view_type (BamfView *view)
 bamf_view_get_view_type: : a #BamfView
gboolean bamf_view_is_on_bus (BamfView *view)
const char * bamf_view_export_on_bus (BamfView *view, GDBusConnection *connection)

Class Documentation

struct _BamfView

Definition at line 67 of file bamf-view.h.

Class Members
BamfDBusItemObjectSkeleton parent
GInitiallyUnowned parent
BamfViewPrivate * priv

Define Documentation

#define BAMF_IS_VIEW (   obj)    (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BAMF_TYPE_VIEW))

Definition at line 30 of file bamf-view.h.

#define BAMF_IS_VIEW_CLASS (   klass)    (G_TYPE_CHECK_CLASS_TYPE ((klass), BAMF_TYPE_VIEW))

Definition at line 32 of file bamf-view.h.

Definition at line 28 of file bamf-view.h.

#define BAMF_VIEW (   obj)    (G_TYPE_CHECK_INSTANCE_CAST ((obj), BAMF_TYPE_VIEW, BamfView))

Definition at line 29 of file bamf-view.h.

#define BAMF_VIEW_CLASS (   klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), BAMF_TYPE_VIEW, BamfViewClass))

Definition at line 31 of file bamf-view.h.

#define BAMF_VIEW_GET_CLASS (   obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), BAMF_TYPE_VIEW, BamfViewClass))

Definition at line 33 of file bamf-view.h.


Typedef Documentation

typedef struct _BamfView

Definition at line 35 of file bamf-view.h.

typedef struct _BamfViewClass

Definition at line 36 of file bamf-view.h.

typedef struct _BamfViewPrivate

Definition at line 37 of file bamf-view.h.


Function Documentation

void bamf_view_add_child ( BamfView *  view,
BamfView *  child 
)

Definition at line 262 of file bamf-view.c.

{
  const char * added;

  g_return_if_fail (BAMF_IS_VIEW (view));
  g_return_if_fail (BAMF_IS_VIEW (child));

  g_signal_connect (G_OBJECT (child), "closed-internal",
                    (GCallback) bamf_view_handle_child_closed, view);

  /* Make sure our parent child lists are ok, pay attention to whose list you add parents to */
  view->priv->children = g_list_prepend (view->priv->children, child);
  child->priv->parents = g_list_prepend (child->priv->parents, view);

  // Do this by hand so we can pass and object instead of a string
  if (BAMF_VIEW_GET_CLASS (view)->child_added)
    BAMF_VIEW_GET_CLASS (view)->child_added (view, child);

  added = bamf_view_get_path (child);
  g_signal_emit_by_name (view, "child-added", added);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void bamf_view_close ( BamfView *  view)

Definition at line 137 of file bamf-view.c.

{
  BamfViewPrivate *priv;
  gboolean emit = TRUE;
  GList *l;

  g_return_if_fail (BAMF_IS_VIEW (view));
  priv = view->priv;

  if (priv->closed)
    return;

  priv->closed = TRUE;

  if (BAMF_VIEW_GET_CLASS (view)->closed)
    {
      emit = !BAMF_VIEW_GET_CLASS (view)->closed (view);
    }

  if (priv->children)
    {
      for (l = priv->children; l; l = l->next)
        {
          if (BAMF_IS_VIEW (l->data))
            bamf_view_remove_child (view, l->data);
        }
      g_list_free (priv->children);
      priv->children = NULL;
    }

  if (emit)
    {
      g_object_ref (view);
      g_signal_emit (view, view_signals[CLOSED_INTERNAL], 0);
      g_signal_emit_by_name (view, "closed");
      g_object_unref (view);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

const char* bamf_view_export_on_bus ( BamfView *  view,
GDBusConnection *  connection 
)

Definition at line 448 of file bamf-view.c.

{
  char *path = NULL;
  GList *ifaces, *l;
  GError *error = NULL;

  g_return_val_if_fail (BAMF_IS_VIEW (view), NULL);
  g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), NULL);

  if (!view->priv->path)
    {
      char *stable_name = bamf_view_get_stable_bus_name (view);
      path = g_strdup_printf ("%s/%s", BAMF_DBUS_PATH, stable_name);
      g_free (stable_name);

      BAMF_VIEW_GET_CLASS (view)->names = g_list_prepend (BAMF_VIEW_GET_CLASS (view)->names, path);
      view->priv->path = path;

      ifaces = g_dbus_object_get_interfaces (G_DBUS_OBJECT (view));

      /* The dbus object interface list is in reversed order, we try to export
       * the interfaces in bottom to top order (BamfView should be the first) */
      for (l = g_list_last(ifaces); l; l = l->prev)
        {
          g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (l->data),
                                            connection, path, &error);
        }

      if (error)
        {
          g_critical ("Can't register BAMF view: %s", error->message);
          g_error_free (error);
        }
      else
        {
          g_signal_emit (view, view_signals[EXPORTED], 0);
        }

      g_list_free_full (ifaces, g_object_unref);
    }

  return view->priv->path;
}

Here is the call graph for this function:

Here is the caller graph for this function:

GList* bamf_view_get_children ( BamfView *  view)

bamf_view_get_children: : a #BamfView

Note: Makes sever dbus calls the first time this is called on a view. Dbus messaging is reduced afterwards.

Returns: (element-type Bamf.View) (transfer container): Returns a list of #BamfView which must be freed after usage. Elements of the list are owned by bamf and should not be unreffed.

Definition at line 146 of file bamf-view.c.

{
  char ** children;
  int i, len;
  GList *results = NULL;
  GError *error = NULL;
  BamfViewPrivate *priv;

  g_return_val_if_fail (BAMF_IS_VIEW (view), NULL);

  if (BAMF_VIEW_GET_CLASS (view)->get_children)
    return BAMF_VIEW_GET_CLASS (view)->get_children (view);

  if (!_bamf_view_remote_ready (view))
    return NULL;

  priv = view->priv;

  if (priv->cached_children)
    return g_list_copy (priv->cached_children);

  if (!dbus_g_proxy_call (priv->proxy,
                          "Children",
                          &error,
                          G_TYPE_INVALID,
                          G_TYPE_STRV, &children,
                          G_TYPE_INVALID))
    {
      g_warning ("Unable to fetch children: %s\n", error->message);
      g_error_free (error);
      return NULL;
    }

  if (!children)
    return NULL;

  len = g_strv_length (children);

  for (i = len-1; i >= 0; i--)
    {
      view = _bamf_factory_view_for_path (_bamf_factory_get_default (), children[i]);
      results = g_list_prepend (results, g_object_ref (view));
    }

  priv->cached_children = results;
  return g_list_copy (priv->cached_children);
}

Here is the call graph for this function:

Here is the caller graph for this function:

GVariant* bamf_view_get_children_paths ( BamfView *  view)

Definition at line 185 of file bamf-view.c.

{
  GVariantBuilder b;
  GList *l;

  g_return_val_if_fail (BAMF_IS_VIEW (view), NULL);

  g_variant_builder_init (&b, G_VARIANT_TYPE ("(as)"));
  g_variant_builder_open (&b, G_VARIANT_TYPE ("as"));

  for (l = view->priv->children; l; l = l->next)
    {
      BamfView *child = l->data;
      const char *path = bamf_view_get_path (child);

      if (!path)
        continue;

      g_variant_builder_add (&b, "s", path);
    }

  g_variant_builder_close (&b);

  return g_variant_builder_end (&b);
}

Here is the call graph for this function:

Here is the caller graph for this function:

const char* bamf_view_get_icon ( BamfView *  view)

bamf_view_get_icon: : a #BamfView

Gets the icon of a view. This icon is used to visually represent the view.

Definition at line 340 of file bamf-view.c.

{
  BamfViewPrivate *priv;
  char *icon = NULL;
  GError *error = NULL;

  g_return_val_if_fail (BAMF_IS_VIEW (self), NULL);
  priv = self->priv;
  
  if (BAMF_VIEW_GET_CLASS (self)->get_icon)
    return BAMF_VIEW_GET_CLASS (self)->get_icon (self);

  if (!_bamf_view_remote_ready (self))
    return g_strdup (priv->local_icon);

  if (!dbus_g_proxy_call (priv->proxy,
                          "Icon",
                          &error,
                          G_TYPE_INVALID,
                          G_TYPE_STRING, &icon,
                          G_TYPE_INVALID))
    {
      g_warning ("Failed to fetch icon: %s", error->message);
      g_error_free (error);
      
      return NULL;
    }

  if (icon && icon[0] == '\0')
    {
      g_free (icon);
      return NULL;
    }

  return icon;
}

Here is the call graph for this function:

Here is the caller graph for this function:

const char* bamf_view_get_name ( BamfView *  view)

bamf_view_get_name: : a #BamfView

Gets the name of a view. This name is a short name best used to represent the view with text.

Definition at line 378 of file bamf-view.c.

{
  BamfViewPrivate *priv;
  char *name = NULL;
  GError *error = NULL;

  g_return_val_if_fail (BAMF_IS_VIEW (self), NULL);
  priv = self->priv;
  
  if (BAMF_VIEW_GET_CLASS (self)->get_name)
    return BAMF_VIEW_GET_CLASS (self)->get_name (self);

  if (!_bamf_view_remote_ready (self))
    return g_strdup (priv->local_name);
    
  if (!dbus_g_proxy_call (priv->proxy,
                          "Name",
                          &error,
                          G_TYPE_INVALID,
                          G_TYPE_STRING, &name,
                          G_TYPE_INVALID))
    {
      g_warning ("Failed to fetch name: %s", error->message);
      g_error_free (error);
      
      return NULL;
    }

  if (name && name[0] == '\0')
    {
      g_free (name);
      return NULL;
    }

  return name;
}

Here is the call graph for this function:

Here is the caller graph for this function:

BamfView* bamf_view_get_parent ( BamfView *  view)
const char* bamf_view_get_parent_path ( BamfView *  view)
GVariant* bamf_view_get_parent_paths ( BamfView *  view)

Definition at line 220 of file bamf-view.c.

{
  GVariantBuilder b;
  GList *l;

  g_return_val_if_fail (BAMF_IS_VIEW (view), NULL);

  g_variant_builder_init (&b, G_VARIANT_TYPE ("(as)"));
  g_variant_builder_open (&b, G_VARIANT_TYPE ("as"));

  for (l = view->priv->parents; l; l = l->next)
    {
      BamfView *parent = l->data;
      const char *path = bamf_view_get_path (parent);

      if (!path)
        continue;

      g_variant_builder_add (&b, "s", path);
    }

  g_variant_builder_close (&b);

  return g_variant_builder_end (&b);
}

Here is the call graph for this function:

Here is the caller graph for this function:

GList* bamf_view_get_parents ( BamfView *  view)

Definition at line 247 of file bamf-view.c.

{
  g_return_val_if_fail (BAMF_IS_VIEW (view), NULL);

  return view->priv->parents;
}

Here is the caller graph for this function:

const char* bamf_view_get_path ( BamfView *  view)

Definition at line 177 of file bamf-view.c.

{
  g_return_val_if_fail (BAMF_IS_VIEW (view), NULL);

  return view->priv->path;
}

Here is the caller graph for this function:

GType bamf_view_get_type ( void  )
const char* bamf_view_get_view_type ( BamfView *  view)

bamf_view_get_view_type: : a #BamfView

The view type of a window is a short string used to represent all views of the same class. These descriptions should not be used to do casting as they are not considered stable.

Returns: (transfer full): A gchar*

Definition at line 425 of file bamf-view.c.

{
  BamfViewPrivate *priv;
  char *type = NULL;
  GError *error = NULL;

  g_return_val_if_fail (BAMF_IS_VIEW (self), NULL);
  priv = self->priv;
  
  if (BAMF_VIEW_GET_CLASS (self)->view_type)
    return BAMF_VIEW_GET_CLASS (self)->view_type (self);
  
  if (priv->type)
    return priv->type;

  if (!dbus_g_proxy_call (priv->proxy,
                          "ViewType",
                          &error,
                          G_TYPE_INVALID,
                          G_TYPE_STRING, &type,
                          G_TYPE_INVALID))
    {
      g_warning ("Failed to fetch view type at %s: %s", dbus_g_proxy_get_path (priv->proxy), error ? error->message : "");
      g_error_free (error);
      return NULL;
    }

  priv->type = type;
  return type;
}

Here is the caller graph for this function:

gboolean bamf_view_is_active ( BamfView *  view)

bamf_view_is_active: : a #BamfView

Determines if the view is currently active and focused by the user. Useful for an active window indicator.

Definition at line 236 of file bamf-view.c.

{
  g_return_val_if_fail (BAMF_IS_VIEW (view), FALSE);

  if (BAMF_VIEW_GET_CLASS (view)->is_active)
    return BAMF_VIEW_GET_CLASS (view)->is_active (view);

  return bamf_view_get_boolean (view, "IsActive", BAMF_VIEW_ACTIVE_FLAG);

}

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean bamf_view_is_on_bus ( BamfView *  view)

Definition at line 493 of file bamf-view.c.

{
  g_return_val_if_fail (BAMF_IS_VIEW (view), FALSE);
  GDBusInterfaceSkeleton *dbus_iface;
  const gchar *exported_path;

  dbus_iface = G_DBUS_INTERFACE_SKELETON (view->priv->dbus_iface);
  exported_path = g_dbus_interface_skeleton_get_object_path (dbus_iface);

  return (view->priv->path != NULL && exported_path != NULL);
}

Here is the caller graph for this function:

gboolean bamf_view_is_running ( BamfView *  view)

bamf_view_is_running: : a #BamfView

Determines if the view is currently running. Useful for a running window indicator.

Definition at line 257 of file bamf-view.c.

{
  g_return_val_if_fail (BAMF_IS_VIEW (self), FALSE);
  
  if (BAMF_VIEW_GET_CLASS (self)->is_running)
    return BAMF_VIEW_GET_CLASS (self)->is_running (self);

  return bamf_view_get_boolean (self, "IsRunning", BAMF_VIEW_RUNNING_FLAG);
}

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean bamf_view_is_urgent ( BamfView *  view)

bamf_view_is_running: : a #BamfView

Determines if the view is currently requiring attention. Useful for a running window indicator.

Definition at line 268 of file bamf-view.c.

{
  g_return_val_if_fail (BAMF_IS_VIEW (self), FALSE);
  
  if (BAMF_VIEW_GET_CLASS (self)->is_urgent)
    return BAMF_VIEW_GET_CLASS (self)->is_urgent (self);

  return bamf_view_get_boolean (self, "IsUrgent", BAMF_VIEW_URGENT_FLAG);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void bamf_view_remove_child ( BamfView *  view,
BamfView *  child 
)

Definition at line 286 of file bamf-view.c.

{
  const char * removed;

  g_return_if_fail (BAMF_IS_VIEW (view));
  g_return_if_fail (BAMF_IS_VIEW (child));

  g_signal_handlers_disconnect_by_func (child, bamf_view_handle_child_closed, view);

  /* Make sure our parent child lists are ok, pay attention to whose list you add parents to */
  view->priv->children = g_list_remove (view->priv->children, child);
  child->priv->parents = g_list_remove (child->priv->parents, view);

  removed = bamf_view_get_path (child);
  g_signal_emit_by_name (view, "child-removed", removed);

  // Do this by hand so we can pass and object instead of a string
  if (BAMF_VIEW_GET_CLASS (view)->child_removed)
    BAMF_VIEW_GET_CLASS (view)->child_removed (view, child);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void bamf_view_set_active ( BamfView *  view,
gboolean  active 
)

Definition at line 317 of file bamf-view.c.

{
  g_return_if_fail (BAMF_IS_VIEW (view));

  if (active == bamf_view_is_active (view))
    return;

  bamf_dbus_item_view_set_active (view->priv->dbus_iface, active);
  bamf_view_active_changed (view, active);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void bamf_view_set_name ( BamfView *  view,
const char *  name 
)

Definition at line 414 of file bamf-view.c.

{
  g_return_if_fail (BAMF_IS_VIEW (view));

  if (!g_strcmp0 (name, view->priv->name))
    return;

  bamf_view_name_changed (view, view->priv->name, name);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void bamf_view_set_parent ( BamfView *  view,
BamfView *  parent 
)
void bamf_view_set_running ( BamfView *  view,
gboolean  running 
)

Definition at line 359 of file bamf-view.c.

{
  g_return_if_fail (BAMF_IS_VIEW (view));

  if (running == bamf_view_is_running (view))
    return;

  bamf_dbus_item_view_set_running (view->priv->dbus_iface, running);
  bamf_view_running_changed (view, running);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void bamf_view_set_urgent ( BamfView *  view,
gboolean  urgent 
)

Definition at line 338 of file bamf-view.c.

{
  g_return_if_fail (BAMF_IS_VIEW (view));

  if (urgent == bamf_view_is_urgent (view))
    return;

  bamf_dbus_item_view_set_urgent (view->priv->dbus_iface, urgent);
  bamf_view_urgent_changed (view, urgent);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void bamf_view_set_user_visible ( BamfView *  view,
gboolean  user_visible 
)

Definition at line 380 of file bamf-view.c.

{
  g_return_if_fail (BAMF_IS_VIEW (view));

  if (user_visible == bamf_view_user_visible (view))
    return;

  bamf_dbus_item_view_set_user_visible (view->priv->dbus_iface, user_visible);
  bamf_view_user_visible_changed (view, user_visible);
}

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean bamf_view_user_visible ( BamfView *  view)

bamf_view_user_visible: : a #BamfView

Returns a boolean useful for determining if a particular view is "user visible". User visible is a concept relating to whether or not a window should be shown in a launcher tasklist.

Definition at line 248 of file bamf-view.c.

{
  g_return_val_if_fail (BAMF_IS_VIEW (self), FALSE);
  
  return bamf_view_get_boolean (self, "UserVisible", BAMF_VIEW_VISIBLE_FLAG);

}

Here is the call graph for this function:

Here is the caller graph for this function: