Add GetDefaultDevice

Gives you the first device listed in GetDevices.
This commit is contained in:
Bastien Nocera
2008-11-20 10:51:58 +00:00
committed by Daniel Drake
parent ac85e5927e
commit e207203b44
2 changed files with 21 additions and 1 deletions

View File

@ -29,7 +29,8 @@
static gboolean fprint_manager_get_devices(FprintManager *manager, static gboolean fprint_manager_get_devices(FprintManager *manager,
GPtrArray **devices, GError **error); GPtrArray **devices, GError **error);
static gboolean fprint_manager_get_default_device(FprintManager *manager,
const char **device, GError **error);
#include "manager-dbus-glue.h" #include "manager-dbus-glue.h"
static GObjectClass *parent_class = NULL; static GObjectClass *parent_class = NULL;
@ -176,3 +177,18 @@ static gboolean fprint_manager_get_devices(FprintManager *manager,
return TRUE; return TRUE;
} }
static gboolean fprint_manager_get_default_device(FprintManager *manager,
const char **device, GError **error)
{
FprintManagerPrivate *priv = FPRINT_MANAGER_GET_PRIVATE (manager);
GSList *elem = priv->dev_registry;
int num_open = g_slist_length(elem);
if (num_open > 0) {
*device = get_device_path (elem->data);
return TRUE;
} else {
*device = NULL;
return FALSE;
}
}

View File

@ -8,6 +8,10 @@
<arg type="ao" name="devices" direction="out" /> <arg type="ao" name="devices" direction="out" />
</method> </method>
<method name="GetDefaultDevice">
<arg type="o" name="device" direction="out" />
</method>
</interface> </interface>
</node> </node>