No issues found
Tool | Failure ID | Location | Function | Message | Data |
---|---|---|---|---|---|
clang-analyzer | no-output-found | nautilus-progress-info-manager.c | Message(text='Unable to locate XML output from invoke-clang-analyzer') | None |
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
2 /*
3 * Nautilus
4 *
5 * Copyright (C) 2011 Red Hat, Inc.
6 *
7 * Nautilus is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
11 *
12 * Nautilus is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public
18 * License along with this program; see the file COPYING. If not,
19 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
21 *
22 * Author: Cosimo Cecchi <cosimoc@redhat.com>
23 */
24
25 #include <config.h>
26
27 #include "nautilus-progress-info-manager.h"
28
29 struct _NautilusProgressInfoManagerPriv {
30 GList *progress_infos;
31 };
32
33 enum {
34 NEW_PROGRESS_INFO,
35 LAST_SIGNAL
36 };
37
38 static NautilusProgressInfoManager *singleton = NULL;
39
40 static guint signals[LAST_SIGNAL] = { 0, };
41
42 G_DEFINE_TYPE (NautilusProgressInfoManager, nautilus_progress_info_manager,
43 G_TYPE_OBJECT);
44
45 static void
46 nautilus_progress_info_manager_finalize (GObject *obj)
47 {
48 NautilusProgressInfoManager *self = NAUTILUS_PROGRESS_INFO_MANAGER (obj);
49
50 if (self->priv->progress_infos != NULL) {
51 g_list_free_full (self->priv->progress_infos, g_object_unref);
52 }
53
54 G_OBJECT_CLASS (nautilus_progress_info_manager_parent_class)->finalize (obj);
55 }
56
57 static GObject *
58 nautilus_progress_info_manager_constructor (GType type,
59 guint n_props,
60 GObjectConstructParam *props)
61 {
62 GObject *retval;
63
64 if (singleton != NULL) {
65 return g_object_ref (singleton);
66 }
67
68 retval = G_OBJECT_CLASS (nautilus_progress_info_manager_parent_class)->constructor
69 (type, n_props, props);
70
71 singleton = NAUTILUS_PROGRESS_INFO_MANAGER (retval);
72 g_object_add_weak_pointer (retval, (gpointer) &singleton);
73
74 return retval;
75 }
76
77 static void
78 nautilus_progress_info_manager_init (NautilusProgressInfoManager *self)
79 {
80 self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, NAUTILUS_TYPE_PROGRESS_INFO_MANAGER,
81 NautilusProgressInfoManagerPriv);
82 }
83
84 static void
85 nautilus_progress_info_manager_class_init (NautilusProgressInfoManagerClass *klass)
86 {
87 GObjectClass *oclass;
88
89 oclass = G_OBJECT_CLASS (klass);
90 oclass->constructor = nautilus_progress_info_manager_constructor;
91 oclass->finalize = nautilus_progress_info_manager_finalize;
92
93 signals[NEW_PROGRESS_INFO] =
94 g_signal_new ("new-progress-info",
95 G_TYPE_FROM_CLASS (klass),
96 G_SIGNAL_RUN_LAST,
97 0, NULL, NULL,
98 g_cclosure_marshal_VOID__OBJECT,
99 G_TYPE_NONE,
100 1,
101 NAUTILUS_TYPE_PROGRESS_INFO);
102
103 g_type_class_add_private (klass, sizeof (NautilusProgressInfoManagerPriv));
104 }
105
106 static void
107 progress_info_finished_cb (NautilusProgressInfo *info,
108 NautilusProgressInfoManager *self)
109 {
110 self->priv->progress_infos =
111 g_list_remove (self->priv->progress_infos, info);
112 }
113
114 NautilusProgressInfoManager *
115 nautilus_progress_info_manager_new (void)
116 {
117 return g_object_new (NAUTILUS_TYPE_PROGRESS_INFO_MANAGER, NULL);
118 }
119
120 void
121 nautilus_progress_info_manager_add_new_info (NautilusProgressInfoManager *self,
122 NautilusProgressInfo *info)
123 {
124 if (g_list_find (self->priv->progress_infos, info) != NULL) {
125 g_warning ("Adding two times the same progress info object to the manager");
126 return;
127 }
128
129 self->priv->progress_infos =
130 g_list_prepend (self->priv->progress_infos, g_object_ref (info));
131
132 g_signal_connect (info, "finished",
133 G_CALLBACK (progress_info_finished_cb), self);
134
135 g_signal_emit (self, signals[NEW_PROGRESS_INFO], 0, info);
136 }
137
138 GList *
139 nautilus_progress_info_manager_get_all_infos (NautilusProgressInfoManager *self)
140 {
141 return self->priv->progress_infos;
142 }