summaryrefslogtreecommitdiff
path: root/thunar-volman/tvm-context.c
blob: 5629173b4eb256cd977960677ccc835ad7ccd374 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/* vi:set et ai sw=2 sts=2 ts=2: */
/*-
 * Copyright (c) 2010 Jannis Pohlmann <jannis@xfce.org>
 *
 * This program is free software; you can redistribute it and/or 
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of 
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public 
 * License along with this program; if not, write to the Free 
 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <glib.h>
#include <gio/gio.h>

#include <gudev/gudev.h>

#include <xfconf/xfconf.h>

#include <thunar-volman/tvm-context.h>
#include <thunar-volman/tvm-device.h>



TvmContext *
tvm_context_new (GUdevClient   *client,
                 GUdevDevice   *device,
                 XfconfChannel *channel,
                 GMainLoop     *loop,
                 GError       **error)
{
  TvmContext *context;

  g_return_val_if_fail (G_UDEV_IS_CLIENT (client), NULL);
  g_return_val_if_fail (G_UDEV_IS_DEVICE (device), NULL);
  g_return_val_if_fail (XFCONF_IS_CHANNEL (channel), NULL);
  g_return_val_if_fail (loop != NULL, NULL);
  g_return_val_if_fail (error == NULL || *error == NULL, NULL);

  context = g_slice_new0 (TvmContext);

  context->client = g_object_ref (client);
  context->device = g_object_ref (device);
  context->channel = g_object_ref (channel);
  context->error = error;
  context->loop = g_main_loop_ref (loop);
  context->handlers = NULL;
  context->monitor = g_volume_monitor_get ();

  return context;
}



void
tvm_context_free (TvmContext *context)
{
  if (context == NULL)
    return;

  g_main_loop_unref (context->loop);

  g_list_free (context->handlers);

  g_object_unref (context->monitor);
  g_object_unref (context->channel);
  g_object_unref (context->device);
  g_object_unref (context->client);

  g_slice_free (TvmContext, context);
}



gboolean
tvm_context_run (gpointer user_data)
{
  TvmContext *context = user_data;
  tvm_device_added (context);

  return FALSE;
}