93
update_info_cb (GObject *source_object,
97
NautilusTrashMonitor *trash_monitor;
100
const char * const *names;
104
trash_monitor = NAUTILUS_TRASH_MONITOR (user_data);
93
update_icon (NautilusTrashMonitor *trash_monitor)
95
g_clear_object (&trash_monitor->details->icon);
97
if (trash_monitor->details->empty) {
98
trash_monitor->details->icon = g_themed_icon_new (NAUTILUS_ICON_TRASH);
100
trash_monitor->details->icon = g_themed_icon_new (NAUTILUS_ICON_TRASH_FULL);
105
update_empty_info (NautilusTrashMonitor *trash_monitor,
108
if (trash_monitor->details->empty == is_empty) {
106
info = g_file_query_info_finish (G_FILE (source_object),
110
icon = g_file_info_get_icon (info);
113
g_object_unref (trash_monitor->details->icon);
114
trash_monitor->details->icon = g_object_ref (icon);
116
if (G_IS_THEMED_ICON (icon)) {
117
names = g_themed_icon_get_names (G_THEMED_ICON (icon));
118
for (i = 0; names[i] != NULL; i++) {
119
if (strcmp (names[i], NAUTILUS_ICON_TRASH_FULL) == 0) {
125
if (trash_monitor->details->empty != empty) {
126
trash_monitor->details->empty = empty;
128
/* trash got empty or full, notify everyone who cares */
129
g_signal_emit (trash_monitor,
130
signals[TRASH_STATE_CHANGED], 0,
131
trash_monitor->details->empty);
134
g_object_unref (info);
112
trash_monitor->details->empty = is_empty;
113
update_icon (trash_monitor);
115
/* trash got empty or full, notify everyone who cares */
116
g_signal_emit (trash_monitor,
117
signals[TRASH_STATE_CHANGED], 0,
118
trash_monitor->details->empty);
122
enumerate_next_files_cb (GObject *source,
126
NautilusTrashMonitor *trash_monitor = user_data;
129
infos = g_file_enumerator_next_files_finish (G_FILE_ENUMERATOR (source), res, NULL);
131
update_empty_info (trash_monitor, TRUE);
133
update_empty_info (trash_monitor, FALSE);
134
g_list_free_full (infos, g_object_unref);
137
137
g_object_unref (trash_monitor);
141
enumerate_children_cb (GObject *source,
145
GFileEnumerator *enumerator;
146
NautilusTrashMonitor *trash_monitor = user_data;
148
enumerator = g_file_enumerate_children_finish (G_FILE (source), res, NULL);
150
update_empty_info (trash_monitor, TRUE);
151
g_object_unref (trash_monitor);
155
g_file_enumerator_next_files_async (enumerator, 1,
156
G_PRIORITY_DEFAULT, NULL,
157
enumerate_next_files_cb, trash_monitor);
158
g_object_unref (enumerator);
141
162
schedule_update_info (NautilusTrashMonitor *trash_monitor)
145
166
location = g_file_new_for_uri ("trash:///");
147
g_file_query_info_async (location,
148
G_FILE_ATTRIBUTE_STANDARD_ICON,
150
update_info_cb, g_object_ref (trash_monitor));
167
g_file_enumerate_children_async (location,
168
G_FILE_ATTRIBUTE_STANDARD_TYPE,
169
G_FILE_QUERY_INFO_NONE,
170
G_PRIORITY_DEFAULT, NULL,
171
enumerate_children_cb, g_object_ref (trash_monitor));
152
173
g_object_unref (location);