Back to index

bamf  0.2.120
Classes | Defines | Typedefs | Enumerations | Functions
bamf-view.h File Reference
#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  _BamfView
struct  _BamfViewClass

Defines

#define BAMF_TYPE_VIEW   (bamf_view_get_type ())
#define BAMF_VIEW(obj)
#define BAMF_VIEW_CLASS(klass)
#define BAMF_IS_VIEW(obj)
#define BAMF_IS_VIEW_CLASS(klass)
#define BAMF_VIEW_GET_CLASS(obj)

Typedefs

typedef struct _BamfView
typedef struct _BamfViewClass
typedef struct _BamfViewPrivate

Enumerations

enum  BamfClickBehavior {
  BAMF_CLICK_BEHAVIOR_NONE, BAMF_CLICK_BEHAVIOR_OPEN, BAMF_CLICK_BEHAVIOR_FOCUS, BAMF_CLICK_BEHAVIOR_FOCUS_ALL,
  BAMF_CLICK_BEHAVIOR_MINIMIZE, BAMF_CLICK_BEHAVIOR_RESTORE, BAMF_CLICK_BEHAVIOR_RESTORE_ALL, BAMF_CLICK_BEHAVIOR_PICKER
}

Functions

GType bamf_view_get_type (void) G_GNUC_CONST
GList * bamf_view_get_children (BamfView *view)
 bamf_view_get_children: : a #BamfView
gboolean bamf_view_is_closed (BamfView *view)
 bamf_view_is_active: : a #BamfView
gboolean bamf_view_is_active (BamfView *view)
 bamf_view_is_active: : a #BamfView
gboolean bamf_view_is_running (BamfView *view)
 bamf_view_is_running: : a #BamfView
gboolean bamf_view_is_urgent (BamfView *view)
 bamf_view_is_running: : a #BamfView
gchar * bamf_view_get_name (BamfView *view)
 bamf_view_get_name: : a #BamfView
gchar * bamf_view_get_icon (BamfView *view)
 bamf_view_get_icon: : a #BamfView
gboolean bamf_view_user_visible (BamfView *view)
 bamf_view_user_visible: : a #BamfView
const gchar * bamf_view_get_view_type (BamfView *view)
 bamf_view_get_view_type: : a #BamfView
void bamf_view_set_sticky (BamfView *view, gboolean value)
gboolean bamf_view_is_sticky (BamfView *view)
BamfClickBehavior bamf_view_get_click_suggestion (BamfView *view)

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)
Value:
(G_TYPE_CHECK_INSTANCE_TYPE ((obj),\
        BAMF_TYPE_VIEW))

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

#define BAMF_IS_VIEW_CLASS (   klass)
Value:
(G_TYPE_CHECK_CLASS_TYPE ((klass),\
        BAMF_TYPE_VIEW))

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

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

#define BAMF_VIEW (   obj)
Value:
(G_TYPE_CHECK_INSTANCE_CAST ((obj),\
        BAMF_TYPE_VIEW, BamfView))

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

#define BAMF_VIEW_CLASS (   klass)
Value:
(G_TYPE_CHECK_CLASS_CAST ((klass),\
        BAMF_TYPE_VIEW, BamfViewClass))

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

#define BAMF_VIEW_GET_CLASS (   obj)
Value:
(G_TYPE_INSTANCE_GET_CLASS ((obj),\
        BAMF_TYPE_VIEW, BamfViewClass))

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


Typedef Documentation

typedef struct _BamfView

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

typedef struct _BamfViewClass

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

typedef struct _BamfViewPrivate

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


Enumeration Type Documentation

Enumerator:
BAMF_CLICK_BEHAVIOR_NONE 
BAMF_CLICK_BEHAVIOR_OPEN 
BAMF_CLICK_BEHAVIOR_FOCUS 
BAMF_CLICK_BEHAVIOR_FOCUS_ALL 
BAMF_CLICK_BEHAVIOR_MINIMIZE 
BAMF_CLICK_BEHAVIOR_RESTORE 
BAMF_CLICK_BEHAVIOR_RESTORE_ALL 
BAMF_CLICK_BEHAVIOR_PICKER 

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


Function Documentation

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);
}

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

{
  g_return_val_if_fail (BAMF_IS_VIEW (self), BAMF_CLICK_BEHAVIOR_NONE);

  if (BAMF_VIEW_GET_CLASS (self)->click_behavior)
    return BAMF_VIEW_GET_CLASS (self)->click_behavior (self);
    
  return BAMF_CLICK_BEHAVIOR_NONE;
}
gchar* 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;
}
gchar* 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;
}
GType bamf_view_get_type ( void  )
const gchar* 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;
}
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);

}
gboolean bamf_view_is_closed ( BamfView *  view)

bamf_view_is_active: : a #BamfView

Determines if the view is closed or not.

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

{
  g_return_val_if_fail (BAMF_IS_VIEW (view), TRUE);

  return view->priv->is_closed;
}
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);
}
gboolean bamf_view_is_sticky ( BamfView *  view)

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

{
  g_return_val_if_fail (BAMF_IS_VIEW (view), FALSE);
  
  return view->priv->sticky;
}

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);
}
void bamf_view_set_sticky ( BamfView *  view,
gboolean  value 
)

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

{
  g_return_if_fail (BAMF_IS_VIEW (view));
  
  if (value == view->priv->sticky)
    return;

  view->priv->sticky = value;
  
  if (value)
    g_object_ref_sink (view);
  else
    g_object_unref (view);
}
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);

}