static void files_changed_cb (GFileMonitor *monitor, GFile *file, GFile *other_file, GFileMonitorEvent event_type, gpointer user_data) { BgPicturesSource *self = BG_PICTURES_SOURCE (user_data); char *uri; switch (event_type) { case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT: file_added (file, self); break; case G_FILE_MONITOR_EVENT_DELETED: uri = g_file_get_uri (file); bg_pictures_source_remove (self, uri); g_free (uri); break; default: return; } }
void DjVuFileCache::add_file(const GP<DjVuFile> & file) { DEBUG_MSG("DjVuFileCache::add_file(): trying to add a new item\n"); DEBUG_MAKE_INDENT(3); GCriticalSectionLock lock(&class_lock); // See if the file is already cached GPosition pos; for(pos=list;pos;++pos) if (list[pos]->get_file()==file) break; if (pos) list[pos]->refresh(); // Refresh the timestamp else { // Doesn't exist in the list yet int _max_size=enabled ? max_size : 0; if (max_size<0) _max_size=max_size; int add_size=file->get_memory_usage(); if (_max_size>=0 && add_size>_max_size) { DEBUG_MSG("but this item is way too large => doing nothing\n"); return; } if (_max_size>=0) clear_to_size(_max_size-add_size); list.append(new Item(file)); cur_size+=add_size; file_added(file); } }