Back to index

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

Go to the source code of this file.

Classes

struct  _BamfMatcher
struct  _BamfMatcherClass

Defines

#define BAMF_TYPE_MATCHER   (bamf_matcher_get_type ())
#define BAMF_MATCHER(obj)
#define BAMF_MATCHER_CLASS(klass)
#define BAMF_IS_MATCHER(obj)
#define BAMF_IS_MATCHER_CLASS(klass)
#define BAMF_MATCHER_GET_CLASS(obj)

Typedefs

typedef struct _BamfMatcher
typedef struct _BamfMatcherClass
typedef struct _BamfMatcherPrivate

Functions

GType bamf_matcher_get_type (void) G_GNUC_CONST
BamfMatcher * bamf_matcher_get_default (void)
 bamf_matcher_get_default: : a #BamfMatcher
BamfApplication * bamf_matcher_get_active_application (BamfMatcher *matcher)
 bamf_matcher_get_active_application: : a #BamfMatcher
BamfWindow * bamf_matcher_get_active_window (BamfMatcher *matcher)
 bamf_matcher_get_active_window: : a #BamfMatcher
BamfApplication * bamf_matcher_get_application_for_xid (BamfMatcher *matcher, guint32 xid)
 bamf_matcher_get_application_for_xid: : a #BamfMatcher : The XID to search for
BamfApplication * bamf_matcher_get_application_for_window (BamfMatcher *matcher, BamfWindow *window)
 bamf_matcher_get_application_for_window: : a #BamfMatcher : The window to look for
gboolean bamf_matcher_application_is_running (BamfMatcher *matcher, const gchar *application)
GList * bamf_matcher_get_applications (BamfMatcher *matcher)
 bamf_matcher_get_applications: : a #BamfMatcher
void bamf_matcher_register_favorites (BamfMatcher *matcher, const gchar **favorites)
 bamf_matcher_register_favorites: : a #BamfMatcher : an array of strings, each containing an absolute path to a .desktop file
GList * bamf_matcher_get_running_applications (BamfMatcher *matcher)
 bamf_matcher_get_running_applications: : a #BamfMatcher
GList * bamf_matcher_get_tabs (BamfMatcher *matcher)
 bamf_matcher_get_tabs: : a #BamfMatcher
GArray * bamf_matcher_get_xids_for_application (BamfMatcher *matcher, const gchar *application)
 bamf_matcher_get_applications: : a #BamfMatcher
GList * bamf_matcher_get_windows (BamfMatcher *matcher)
 bamf_matcher_get_windows: : a #BamfMatcher
GList * bamf_matcher_get_window_stack_for_monitor (BamfMatcher *matcher, gint monitor)
 bamf_matcher_get_window_stack_for_monitor: : a #BamfMatcher : the monitor you want the stack from, negative value to get all
BamfApplication * bamf_matcher_get_application_for_desktop_file (BamfMatcher *matcher, const gchar *desktop_file_path, gboolean create_if_not_found)

Class Documentation

struct _BamfMatcher

Definition at line 57 of file bamf-matcher.h.

Class Members
GObject parent
BamfDBusMatcherSkeleton parent
BamfMatcherPrivate * priv

Define Documentation

#define BAMF_IS_MATCHER (   obj)
Value:
(G_TYPE_CHECK_INSTANCE_TYPE ((obj),\
        BAMF_TYPE_MATCHER))

Definition at line 44 of file bamf-matcher.h.

#define BAMF_IS_MATCHER_CLASS (   klass)
Value:
(G_TYPE_CHECK_CLASS_TYPE ((klass),\
        BAMF_TYPE_MATCHER))

Definition at line 47 of file bamf-matcher.h.

#define BAMF_MATCHER (   obj)
Value:
(G_TYPE_CHECK_INSTANCE_CAST ((obj),\
        BAMF_TYPE_MATCHER, BamfMatcher))

Definition at line 38 of file bamf-matcher.h.

#define BAMF_MATCHER_CLASS (   klass)
Value:
(G_TYPE_CHECK_CLASS_CAST ((klass),\
        BAMF_TYPE_MATCHER, BamfMatcherClass))

Definition at line 41 of file bamf-matcher.h.

#define BAMF_MATCHER_GET_CLASS (   obj)
Value:
(G_TYPE_INSTANCE_GET_CLASS ((obj),\
        BAMF_TYPE_MATCHER, BamfMatcherClass))

Definition at line 50 of file bamf-matcher.h.

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


Typedef Documentation

typedef struct _BamfMatcher

Definition at line 53 of file bamf-matcher.h.

typedef struct _BamfMatcherClass

Definition at line 54 of file bamf-matcher.h.

typedef struct _BamfMatcherPrivate

Definition at line 55 of file bamf-matcher.h.


Function Documentation

gboolean bamf_matcher_application_is_running ( BamfMatcher *  matcher,
const gchar *  application 
)

Definition at line 498 of file bamf-matcher.c.

{
  BamfMatcherPrivate *priv;
  gboolean running = FALSE;
  GError *error = NULL;

  g_return_val_if_fail (BAMF_IS_MATCHER (matcher), FALSE);
  priv = matcher->priv;

  if (!dbus_g_proxy_call (priv->proxy,
                          "ApplicationIsRunning",
                          &error,
                          G_TYPE_STRING, application,
                          G_TYPE_INVALID,
                          G_TYPE_BOOLEAN, &running,
                          G_TYPE_INVALID))
    {
      g_warning ("Failed to fetch path: %s", error->message);
      g_error_free (error);
      
      return FALSE;
    }

  return running;
}

Here is the caller graph for this function:

BamfApplication* bamf_matcher_get_active_application ( BamfMatcher *  matcher)

bamf_matcher_get_active_application: : a #BamfMatcher

Used to fetch the active #BamfApplication.

Returns: (transfer none): The active #BamfApplication.

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

{
  BamfMatcherPrivate *priv;
  BamfView *view;
  char *app = NULL;
  GError *error = NULL;

  g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL);
  priv = matcher->priv;

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

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

  if (!app)
    return NULL;

  BamfFactory *factory = _bamf_factory_get_default ();
  view = _bamf_factory_view_for_path_type (factory, app, BAMF_FACTORY_APPLICATION);
  g_free (app);

  if (!BAMF_IS_APPLICATION (view))
    return NULL;

  return BAMF_APPLICATION (view);
}
BamfWindow* bamf_matcher_get_active_window ( BamfMatcher *  matcher)

bamf_matcher_get_active_window: : a #BamfMatcher

Used to fetch the active #BamfWindow.

Returns: (transfer none): The active #BamfWindow.

Definition at line 401 of file bamf-matcher.c.

{
  BamfMatcherPrivate *priv;
  BamfView *view;
  char *win = NULL;
  GError *error = NULL;

  g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL);
  priv = matcher->priv;

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

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

  if (!win)
    return NULL;

  BamfFactory *factory = _bamf_factory_get_default ();
  view = _bamf_factory_view_for_path_type (factory, win, BAMF_FACTORY_WINDOW);
  g_free (win);

  if (!BAMF_IS_WINDOW (view))
    return NULL;

  return BAMF_WINDOW (view);
}
BamfApplication* bamf_matcher_get_application_for_desktop_file ( BamfMatcher *  matcher,
const gchar *  desktop_file_path,
gboolean  create_if_not_found 
)

Definition at line 732 of file bamf-matcher.c.

{
  BamfApplication *app;
  const gchar ** favs;
  
  app = _bamf_factory_app_for_file (_bamf_factory_get_default (), desktop_file_path, create_if_not_found);
  if (app)
    {
      favs = g_malloc0 (sizeof (gchar *) * 2),
      favs[0] = desktop_file_path;      
      bamf_matcher_register_favorites (matcher, favs);
      g_free (favs);
    }
  return app;
}

Here is the call graph for this function:

BamfApplication* bamf_matcher_get_application_for_window ( BamfMatcher *  matcher,
BamfWindow *  window 
)

bamf_matcher_get_application_for_window: : a #BamfMatcher : The window to look for

Used to fetch the #BamfApplication containing the passed window.

Returns: (transfer container): The #BamfApplication representing the xid passed, or NULL if none exists.

Definition at line 445 of file bamf-matcher.c.

Here is the call graph for this function:

Here is the caller graph for this function:

BamfApplication* bamf_matcher_get_application_for_xid ( BamfMatcher *  matcher,
guint32  xid 
)

bamf_matcher_get_application_for_xid: : a #BamfMatcher : The XID to search for

Used to fetch the #BamfApplication containing the passed xid.

Returns: (transfer container): The #BamfApplication representing the xid passed, or NULL if none exists.

Definition at line 453 of file bamf-matcher.c.

{
  BamfMatcherPrivate *priv;
  BamfView *view;
  char *app = NULL;
  GError *error = NULL;

  g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL);
  priv = matcher->priv;

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

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

  if (!app)
    return NULL;

  BamfFactory *factory = _bamf_factory_get_default ();
  view = _bamf_factory_view_for_path_type (factory, app, BAMF_FACTORY_APPLICATION);
  
  g_free (app);

  if (!BAMF_IS_APPLICATION (view))
    return NULL;

  return BAMF_APPLICATION (view);
}

Here is the call graph for this function:

Here is the caller graph for this function:

GList* bamf_matcher_get_applications ( BamfMatcher *  matcher)

bamf_matcher_get_applications: : a #BamfMatcher

Used to fetch all #BamfApplication's running or not. Application authors who wish to only see running applications should use bamf_matcher_get_running_applications instead. The reason this method is needed is bamf will occasionally track applications which are not currently running for nefarious purposes.

Returns: (element-type Bamf.Application) (transfer container): A list of #BamfApplication's.

Definition at line 526 of file bamf-matcher.c.

{
  BamfMatcherPrivate *priv;
  BamfView *view;
  char **array = NULL;
  int i, len;
  GList *result = NULL;
  GError *error = NULL;

  g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL);
  priv = matcher->priv;

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

  if (!array)
    return NULL;

  BamfFactory *factory = _bamf_factory_get_default ();
  len = g_strv_length (array);
  for (i = len-1; i >= 0; i--)
    {
      view = _bamf_factory_view_for_path_type (factory, array[i], BAMF_FACTORY_APPLICATION);

      if (BAMF_IS_APPLICATION (view))
        result = g_list_prepend (result, view);
    }
  
  g_strfreev (array);
  return result;
}

Here is the call graph for this function:

Here is the caller graph for this function:

BamfMatcher* bamf_matcher_get_default ( void  )

bamf_matcher_get_default: : a #BamfMatcher

Returns the default matcher. This matcher is owned by bamf and shared between other callers.

Returns: (transfer none): A new #BamfMatcher

Definition at line 350 of file bamf-matcher.c.

{
  if (BAMF_IS_MATCHER (default_matcher))
    return g_object_ref (default_matcher);

  return (default_matcher = g_object_new (BAMF_TYPE_MATCHER, NULL));
}
GList* bamf_matcher_get_running_applications ( BamfMatcher *  matcher)

bamf_matcher_get_running_applications: : a #BamfMatcher

Used to fetch all #BamfApplication's which are running.

Returns: (element-type Bamf.Application) (transfer container): A list of #BamfApplication's.

Definition at line 674 of file bamf-matcher.c.

{
  BamfMatcherPrivate *priv;
  BamfView *view;
  char **array = NULL;
  int i, len;
  GList *result = NULL;
  GError *error = NULL;

  g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL);
  priv = matcher->priv;

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

  if (!array)
    return NULL;

  BamfFactory *factory = _bamf_factory_get_default ();
  len = g_strv_length (array);
  for (i = len-1; i >= 0; i--)
    {
      view = _bamf_factory_view_for_path_type (factory, array[i], BAMF_FACTORY_APPLICATION);

      if (BAMF_IS_APPLICATION (view))
        result = g_list_prepend (result, view);
    }

  g_strfreev (array);
  return result;
}

Here is the call graph for this function:

GList* bamf_matcher_get_tabs ( BamfMatcher *  matcher)

bamf_matcher_get_tabs: : a #BamfMatcher

Used to fetch all #BamfView's representing tabs. Currently unused.

Returns: (element-type Bamf.View) (transfer container): A list of #BamfViews's.

Definition at line 717 of file bamf-matcher.c.

{
  /* FIXME */
  return NULL;
}
GType bamf_matcher_get_type ( void  )
GList* bamf_matcher_get_window_stack_for_monitor ( BamfMatcher *  matcher,
gint  monitor 
)

bamf_matcher_get_window_stack_for_monitor: : a #BamfMatcher : the monitor you want the stack from, negative value to get all

Used to fetch all windows that BAMF knows about in the requested screen, in stacking bottom-to-top order.

Returns: (element-type Bamf.View) (transfer container): A list of #BamfWindow.

Definition at line 612 of file bamf-matcher.c.

{
  BamfMatcherPrivate *priv;
  BamfView *view;
  char **array = NULL;
  int i, len;
  GList *result = NULL;
  GError *error = NULL;

  g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL);
  priv = matcher->priv;

  if (!dbus_g_proxy_call (priv->proxy,
                          "WindowStackForMonitor",
                          &error,
                          G_TYPE_INT,
                          monitor,
                          G_TYPE_INVALID,
                          G_TYPE_STRV, &array,
                          G_TYPE_INVALID))
    {
      g_warning ("Failed to fetch paths: %s", error->message);
      g_error_free (error);
      
      return NULL;
    }

  if (!array)
    return NULL;

  BamfFactory *factory = _bamf_factory_get_default ();
  len = g_strv_length (array);
  for (i = len-1; i >= 0; i--)
    {
      view = _bamf_factory_view_for_path_type (factory, array[i], BAMF_FACTORY_WINDOW);

      if (BAMF_IS_WINDOW (view))
        result = g_list_prepend (result, view);
    }
  
  g_strfreev (array);
  return result;
}
GList* bamf_matcher_get_windows ( BamfMatcher *  matcher)

bamf_matcher_get_windows: : a #BamfMatcher

Used to fetch all windows that BAMF knows about.

Returns: (element-type Bamf.View) (transfer container): A list of windows.

Definition at line 569 of file bamf-matcher.c.

{
  BamfMatcherPrivate *priv;
  BamfView *view;
  char **array = NULL;
  int i, len;
  GList *result = NULL;
  GError *error = NULL;

  g_return_val_if_fail (BAMF_IS_MATCHER (matcher), NULL);
  priv = matcher->priv;

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

  if (!array)
    return NULL;

  BamfFactory *factory = _bamf_factory_get_default ();
  len = g_strv_length (array);
  for (i = len-1; i >= 0; i--)
    {
      view = _bamf_factory_view_for_path_type (factory, array[i], BAMF_FACTORY_WINDOW);

      if (BAMF_IS_WINDOW (view))
        result = g_list_prepend (result, view);
    }
  
  g_strfreev (array);
  return result;
}

Here is the call graph for this function:

GArray* bamf_matcher_get_xids_for_application ( BamfMatcher *  matcher,
const gchar *  application 
)

bamf_matcher_get_applications: : a #BamfMatcher

Used to fetch all xid's associated with an application. Useful for performing window

Returns: (element-type guint32) (transfer none): A list of xids.

Definition at line 724 of file bamf-matcher.c.

{
  /* FIXME */
  return NULL;
}
void bamf_matcher_register_favorites ( BamfMatcher *  matcher,
const gchar **  favorites 
)

bamf_matcher_register_favorites: : a #BamfMatcher : an array of strings, each containing an absolute path to a .desktop file

Used to effect how bamf performs matching. Desktop files passed to this method will be prefered by bamf to system desktop files.

Definition at line 657 of file bamf-matcher.c.

{
  BamfMatcherPrivate *priv;

  g_return_if_fail (BAMF_IS_MATCHER (matcher));
  g_return_if_fail (favorites);
  
  priv = matcher->priv;

  dbus_g_proxy_call_no_reply (priv->proxy,
                              "RegisterFavorites",
                              G_TYPE_STRV, favorites,
                              G_TYPE_INVALID);
}

Here is the caller graph for this function: