Back to index

bamf  0.2.120
Classes | Defines | Functions
bamf-control.c File Reference
#include "bamf-tab-source.h"
#include "bamf-matcher.h"
#include "bamf-control.h"
#include "bamf-indicator-source.h"
#include "bamf-daemon.h"

Go to the source code of this file.

Classes

struct  _BamfControlPrivate

Defines

#define BAMF_CONTROL_GET_PRIVATE(obj)

Functions

 G_DEFINE_TYPE (BamfControl, bamf_control, BAMF_DBUS_TYPE_CONTROL_SKELETON)
static void bamf_control_on_launched_callback (GDBusConnection *connection, const gchar *sender_name, const gchar *object_path, const gchar *interface_name, const gchar *signal_name, GVariant *parameters, gpointer user_data)
static void bamf_control_constructed (GObject *object)
static gboolean on_dbus_handle_quit (BamfDBusControl *interface, GDBusMethodInvocation *invocation, BamfControl *self)
static gboolean on_dbus_handle_set_approver_behavior (BamfDBusControl *interface, GDBusMethodInvocation *invocation, gint behavior, BamfControl *self)
static gboolean on_dbus_handle_om_nom_nom_desktop_file (BamfDBusControl *interface, GDBusMethodInvocation *invocation, const gchar *desktop_file, BamfControl *self)
static gboolean on_dbus_handle_register_tab_provider (BamfDBusControl *interface, GDBusMethodInvocation *invocation, const gchar *tab_path, BamfControl *self)
static gboolean on_dbus_handle_register_application_for_pid (BamfDBusControl *interface, GDBusMethodInvocation *invocation, const gchar *application, guint pid, BamfControl *self)
static void bamf_control_init (BamfControl *self)
static void bamf_control_finalize (GObject *object)
static void bamf_control_class_init (BamfControlClass *klass)
void bamf_control_set_approver_behavior (BamfControl *control, gint32 behavior)
void bamf_control_register_application_for_pid (BamfControl *control, const char *application, gint32 pid)
void bamf_control_insert_desktop_file (BamfControl *control, const char *path)
void bamf_control_register_tab_provider (BamfControl *control, const char *sender, const char *path)
static gboolean bamf_control_on_quit (BamfControl *control)
void bamf_control_quit (BamfControl *control)
BamfControl * bamf_control_get_default (void)

Class Documentation

struct _BamfControlPrivate

Definition at line 47 of file bamf-control.c.

Class Members
DBusGConnection * connection
DBusGProxy * proxy
GList * sources

Define Documentation

#define BAMF_CONTROL_GET_PRIVATE (   obj)
Value:
(G_TYPE_INSTANCE_GET_PRIVATE(obj, \
BAMF_TYPE_CONTROL, BamfControlPrivate))

Definition at line 29 of file bamf-control.c.


Function Documentation

static void bamf_control_class_init ( BamfControlClass *  klass) [static]

Definition at line 170 of file bamf-control.c.

{
  GObjectClass *obj_class = G_OBJECT_CLASS (klass);

  obj_class->constructed = bamf_control_constructed;
  obj_class->finalize = bamf_control_finalize;

  g_type_class_add_private (klass, sizeof (BamfControlPrivate));
}

Here is the call graph for this function:

static void bamf_control_constructed ( GObject *  object) [static]

Definition at line 57 of file bamf-control.c.

{
  GDBusConnection *gbus;

  if (G_OBJECT_CLASS (bamf_control_parent_class)->constructed)
    G_OBJECT_CLASS (bamf_control_parent_class)->constructed (object);

  gbus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
  g_dbus_connection_signal_subscribe  (gbus,
                                       NULL,
                                       "org.gtk.gio.DesktopAppInfo",
                                       "Launched",
                                       "/org/gtk/gio/DesktopAppInfo",
                                       NULL,
                                       0,
                                       bamf_control_on_launched_callback,
                                       BAMF_CONTROL (object),
                                       NULL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void bamf_control_finalize ( GObject *  object) [static]

Definition at line 162 of file bamf-control.c.

{
  BamfControl *self = BAMF_CONTROL (object);
  g_list_free_full (self->priv->sources, g_object_unref);
  self->priv->sources = NULL;
}

Here is the caller graph for this function:

BamfControl* bamf_control_get_default ( void  )

Definition at line 240 of file bamf-control.c.

{
  static BamfControl *control;

  if (!BAMF_IS_CONTROL (control))
    {
      control = (BamfControl *) g_object_new (BAMF_TYPE_CONTROL, NULL);
    }

  return control;
}
static void bamf_control_init ( BamfControl *  self) [static]

Definition at line 139 of file bamf-control.c.

{
  self->priv = BAMF_CONTROL_GET_PRIVATE (self);
  self->priv->sources = NULL;

  /* Registering signal callbacks to reply to dbus method calls */
  g_signal_connect (self, "handle-quit",
                    G_CALLBACK (on_dbus_handle_quit), self);

  g_signal_connect (self, "handle-set-approver-behavior",
                    G_CALLBACK (on_dbus_handle_set_approver_behavior), self);

  g_signal_connect (self, "handle-om-nom-nom-desktop-file",
                    G_CALLBACK (on_dbus_handle_om_nom_nom_desktop_file), self);

  g_signal_connect (self, "handle-register-tab-provider",
                    G_CALLBACK (on_dbus_handle_register_tab_provider), self);

  g_signal_connect (self, "handle-register-application-for-pid",
                    G_CALLBACK (on_dbus_handle_register_application_for_pid), self);
}

Here is the call graph for this function:

void bamf_control_insert_desktop_file ( BamfControl *  control,
const char *  path 
)

Definition at line 198 of file bamf-control.c.

{
  BamfMatcher *matcher = bamf_matcher_get_default ();
  bamf_matcher_load_desktop_file (matcher, path);
}

Here is the call graph for this function:

static void bamf_control_on_launched_callback ( GDBusConnection *  connection,
const gchar *  sender_name,
const gchar *  object_path,
const gchar *  interface_name,
const gchar *  signal_name,
GVariant *  parameters,
gpointer  user_data 
) [static]

Definition at line 38 of file bamf-control.c.

{
  const gchar *desktop_file;
  gint64 pid;

  g_variant_get_child (parameters, 0, "^&ay", &desktop_file);
  g_variant_get_child (parameters, 2, "x", &pid);

  bamf_matcher_register_desktop_file_for_pid (bamf_matcher_get_default (),
                                              desktop_file, pid);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static gboolean bamf_control_on_quit ( BamfControl *  control) [static]

Definition at line 226 of file bamf-control.c.

{
  BamfDaemon *daemon = bamf_daemon_get_default ();
  bamf_daemon_stop (daemon);
  return FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void bamf_control_quit ( BamfControl *  control)

Definition at line 234 of file bamf-control.c.

{
  g_idle_add ((GSourceFunc) bamf_control_on_quit, control);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void bamf_control_register_application_for_pid ( BamfControl *  control,
const char *  application,
gint32  pid 
)

Definition at line 189 of file bamf-control.c.

{
  BamfMatcher *matcher = bamf_matcher_get_default ();
  bamf_matcher_register_desktop_file_for_pid (matcher, application, pid);
}

Here is the call graph for this function:

void bamf_control_register_tab_provider ( BamfControl *  control,
const char *  sender,
const char *  path 
)

Definition at line 206 of file bamf-control.c.

{
  BamfTabSource *source;

  if (!path || !sender)
    {
      return;
    }

  source = bamf_tab_source_new (g_strdup (sender), g_strdup (path));

  if (BAMF_IS_TAB_SOURCE (source))
    {
      control->priv->sources = g_list_prepend (control->priv->sources, source);
    }
}

Here is the call graph for this function:

void bamf_control_set_approver_behavior ( BamfControl *  control,
gint32  behavior 
)

Definition at line 181 of file bamf-control.c.

{
  BamfIndicatorSource *indicator_source = bamf_indicator_source_get_default ();
  bamf_indicator_source_set_behavior (indicator_source, behavior);
}

Here is the call graph for this function:

G_DEFINE_TYPE ( BamfControl  ,
bamf_control  ,
BAMF_DBUS_TYPE_CONTROL_SKELETON   
)
static gboolean on_dbus_handle_om_nom_nom_desktop_file ( BamfDBusControl *  interface,
GDBusMethodInvocation *  invocation,
const gchar *  desktop_file,
BamfControl *  self 
) [static]

Definition at line 101 of file bamf-control.c.

{
  bamf_control_insert_desktop_file (self, desktop_file);
  g_dbus_method_invocation_return_value (invocation, NULL);

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static gboolean on_dbus_handle_quit ( BamfDBusControl *  interface,
GDBusMethodInvocation *  invocation,
BamfControl *  self 
) [static]

Definition at line 78 of file bamf-control.c.

{
  bamf_control_quit (self);
  g_dbus_method_invocation_return_value (invocation, NULL);

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static gboolean on_dbus_handle_register_application_for_pid ( BamfDBusControl *  interface,
GDBusMethodInvocation *  invocation,
const gchar *  application,
guint  pid,
BamfControl *  self 
) [static]

Definition at line 126 of file bamf-control.c.

{
  bamf_control_register_application_for_pid (self, application, pid);
  g_dbus_method_invocation_return_value (invocation, NULL);

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static gboolean on_dbus_handle_register_tab_provider ( BamfDBusControl *  interface,
GDBusMethodInvocation *  invocation,
const gchar *  tab_path,
BamfControl *  self 
) [static]

Definition at line 113 of file bamf-control.c.

{
  const gchar *sender = g_dbus_method_invocation_get_sender (invocation);
  bamf_control_register_tab_provider (self, sender, tab_path);
  g_dbus_method_invocation_return_value (invocation, NULL);

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static gboolean on_dbus_handle_set_approver_behavior ( BamfDBusControl *  interface,
GDBusMethodInvocation *  invocation,
gint  behavior,
BamfControl *  self 
) [static]

Definition at line 89 of file bamf-control.c.

{
  bamf_control_set_approver_behavior (self, behavior);
  g_dbus_method_invocation_return_value (invocation, NULL);

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function: